@powerhousedao/reactor-browser 6.2.2-dev.5 → 6.2.2-dev.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +283 -0
  2. package/dist/attachment-service-CghxHYta.d.ts +970 -0
  3. package/dist/attachment-service-CghxHYta.d.ts.map +1 -0
  4. package/dist/client-BaHKLGy5.d.ts +14 -0
  5. package/dist/client-BaHKLGy5.d.ts.map +1 -0
  6. package/dist/{client-u13cr-Vg.js → client-Zz_l9QzI.js} +30 -3
  7. package/dist/client-Zz_l9QzI.js.map +1 -0
  8. package/dist/{client-_Gh2Uf0E.js → client-s_ISz_Zs.js} +30 -4
  9. package/dist/client-s_ISz_Zs.js.map +1 -0
  10. package/dist/{document-by-id-dLYFX-xz.js → document-by-id-DWEQI7wn.js} +48 -43
  11. package/dist/document-by-id-DWEQI7wn.js.map +1 -0
  12. package/dist/document-operations-D0ePGjbp.js +2778 -0
  13. package/dist/document-operations-D0ePGjbp.js.map +1 -0
  14. package/dist/global-CbyAMlZd.d.ts +400 -0
  15. package/dist/global-CbyAMlZd.d.ts.map +1 -0
  16. package/dist/index-CxxxP14A.d.ts +144 -0
  17. package/dist/index-CxxxP14A.d.ts.map +1 -0
  18. package/dist/index-DPq1VjpB.d.ts +345 -0
  19. package/dist/index-DPq1VjpB.d.ts.map +1 -0
  20. package/dist/index.d.ts +177 -695
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +256 -1627
  23. package/dist/index.js.map +1 -1
  24. package/dist/{inspector-proxy-CvQDDxmT.d.ts → inspector-proxy-CaCFdEG4.d.ts} +4 -2
  25. package/dist/inspector-proxy-CaCFdEG4.d.ts.map +1 -0
  26. package/dist/{make-ph-event-functions-BHoLPif5.js → make-ph-event-functions-DBq3iWYn.js} +1 -1
  27. package/dist/{make-ph-event-functions-BHoLPif5.js.map → make-ph-event-functions-DBq3iWYn.js.map} +1 -1
  28. package/dist/{index-DS4W07Y8.d.ts → pglite-CntadC_p-BtEalg1H.d.ts} +2 -142
  29. package/dist/pglite-CntadC_p-BtEalg1H.d.ts.map +1 -0
  30. package/dist/{relational-Dj06-YkI.js → relational-C_0GdGVN.js} +2 -2
  31. package/dist/{relational-Dj06-YkI.js.map → relational-C_0GdGVN.js.map} +1 -1
  32. package/dist/renown-BZabzj4l.js +68 -0
  33. package/dist/renown-BZabzj4l.js.map +1 -0
  34. package/dist/{renown-D-1c_Bvx.js → renown-C7a1ygsj.js} +471 -57
  35. package/dist/renown-C7a1ygsj.js.map +1 -0
  36. package/dist/src/analytics/index.d.ts +1 -1
  37. package/dist/src/analytics/index.js +2 -1
  38. package/dist/src/analytics/index.js.map +1 -1
  39. package/dist/src/graphql/client.d.ts +3 -2
  40. package/dist/src/graphql/client.js +1 -1
  41. package/dist/src/graphql-client/entry.d.ts +4 -0
  42. package/dist/src/graphql-client/entry.js +3 -0
  43. package/dist/src/relational/index.d.ts +1 -1
  44. package/dist/src/relational/index.js +1 -1
  45. package/dist/src/renown/index.d.ts +2 -2
  46. package/dist/src/renown/index.js +3 -2
  47. package/dist/src/rpc/index.d.ts +5 -3
  48. package/dist/src/rpc/index.d.ts.map +1 -1
  49. package/dist/src/rpc/index.js +37 -10
  50. package/dist/src/rpc/index.js.map +1 -1
  51. package/dist/store-DAJq6vSs.js +37 -0
  52. package/dist/store-DAJq6vSs.js.map +1 -0
  53. package/dist/{client-09xv0Dq6.d.ts → types-Bitg5Z5j.d.ts} +25 -13
  54. package/dist/types-Bitg5Z5j.d.ts.map +1 -0
  55. package/dist/{types-CPV0Cnsy.d.ts → types-wGaiXwjh.d.ts} +1 -1
  56. package/dist/{types-CPV0Cnsy.d.ts.map → types-wGaiXwjh.d.ts.map} +1 -1
  57. package/package.json +15 -9
  58. package/dist/client-09xv0Dq6.d.ts.map +0 -1
  59. package/dist/client-_Gh2Uf0E.js.map +0 -1
  60. package/dist/client-u13cr-Vg.js.map +0 -1
  61. package/dist/document-by-id-dLYFX-xz.js.map +0 -1
  62. package/dist/index-D3bV5rcl.d.ts +0 -216
  63. package/dist/index-D3bV5rcl.d.ts.map +0 -1
  64. package/dist/index-DS4W07Y8.d.ts.map +0 -1
  65. package/dist/inspector-proxy-CvQDDxmT.d.ts.map +0 -1
  66. package/dist/renown-D-1c_Bvx.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,580 +1,22 @@
1
- import { C as queueOperations, S as queueActions, _ as getAnalyticsStore, a as setDocumentCache, b as setGlobal, c as useDocumentSafe, d as useGetDocumentAsync, f as useGetDocuments, g as createAnalyticsStore, h as readPromiseState, i as addDocumentCacheEventHandler, l as useDocuments, m as addPromiseState, n as useDocumentsByIds, o as useDocument, p as DocumentCache, r as useDispatch, s as useDocumentCache, t as useDocumentById, u as useGetDocument, v as clearGlobal, w as uploadOperations, x as dispatchActions, y as getGlobal } from "./document-by-id-dLYFX-xz.js";
2
- import { t as makePHEventFunctions } from "./make-ph-event-functions-BHoLPif5.js";
1
+ import { a as setDocumentCache, c as useDocumentSafe, d as useGetDocumentAsync, f as useGetDocuments, h as readPromiseState, i as addDocumentCacheEventHandler, l as useDocuments, m as addPromiseState, n as useDocumentsByIds, o as useDocument, p as DocumentCache, r as useDispatch, s as useDocumentCache, t as useDocumentById, u as useGetDocument, y as dispatchActions } from "./document-by-id-DWEQI7wn.js";
2
+ import { $ as addGraphQLReactorClientEventHandler, $i as makeAuthMiddleware, $n as setIsDeleteCloudDrivesEnabled, $r as useIsDriveAnalyticsEnabled, $t as addIsAnalyticsEnabledEventHandler, A as useNodesInSelectedDrive, Aa as DocumentModelNotFoundError, Ai as phAppConfigSetters, An as addVersionCheckIntervalEventHandler, Ar as useAllowList, At as makeNodeSlug, B as addReactorClientModuleEventHandler, Bi as isGraphQLReactorClient, Bn as setDisabledEditors, Br as useIsAddCloudDrivesEnabled, Bt as addBasePathEventHandler, C as setSelectedTimelineItem, Ca as addModalEventHandler, Ci as useVersionCheckInterval, Cn as addRequiresHardRefreshEventHandler, Cr as setSentryEnv, Ct as extractDriveSlugFromPath, D as useDocumentsInSelectedDrive, Da as showDeleteNodeModal, Di as addIsExternalControlsEnabledEventHandler, Dn as addSentryReleaseEventHandler, Dr as setVersion, Dt as findUuid, E as useDocumentTypesInSelectedDrive, Ea as showCreateDocumentModal, Ei as addIsDragAndDropEnabledEventHandler, En as addSentryEnvEventHandler, Er as setSwitchboardUrl, Et as extractNodeSlugFromPath, F as hideRevisionHistory, Fi as setIsExternalControlsEnabled, Fn as setAllowList, Fr as useDisabledEditors, Ft as addAttachmentServiceEventHandler, G as usePGlite, Gi as SubgraphSdkRegistry, Gn as setIsAddCloudDrivesEnabled, Gr as useIsAnalyticsEnabled, Gt as addEnabledEditorsEventHandler, H as setReactorClientModule, Hi as makeAuthConnectionParams, Hn as setEnabledEditors, Hr as useIsAddLocalDrivesEnabled, Ht as addDefaultDrivesUrlEventHandler, I as setRevisionHistoryVisible, Ii as useAllowedDocumentTypes, In as setAnalyticsDatabaseName, Ir as useDrivesPreserveStrategy, It as setAttachmentService, J as useSync, Ji as signStampedAction, Jn as setIsAddPublicDrivesEnabled, Jr as useIsDeleteCloudDrivesEnabled, Jt as addIsAddCloudDrivesEnabledEventHandler, K as useReactorClient, Ki as describeGraphQLDocument, Kn as setIsAddDriveEnabled, Kr as useIsAnalyticsExternalProcessorsEnabled, Kt as addFileUploadOperationsChunkSizeEventHandler, L as showRevisionHistory, Li as useIsDragAndDropEnabled, Ln as setBasePath, Lr as useEnabledEditors, Lt as useAttachmentService, M as isFolderNodeKind, Ma as DocumentTypeMismatchError, Mi as phDocumentEditorConfigSetters, Mn as addWarnOutdatedAppEventHandler, Mr as useBasePath, Mt as addFeaturesEventHandler, N as sortNodesByName, Na as NoSelectedDocumentError, Ni as setAllowedDocumentTypes, Nn as phGlobalConfigHooks, Nr as useCliVersion, Nt as setFeatures, O as useFileNodesInSelectedDrive, Oa as showPHModal, Oi as isExternalControlsEnabledEventFunctions, On as addStudioModeEventHandler, Or as setVersionCheckInterval, Ot as getPathWithoutBase, P as addRevisionHistoryVisibleEventHandler, Pa as UnsupportedDocumentTypeError, Pi as setIsDragAndDropEnabled, Pn as phGlobalConfigSetters, Pr as useDefaultDrivesUrl, Pt as useFeatures, Q as usePackageDiscoveryService, Qi as ambientRenownTokenProvider, Qn as setIsCloudDrivesEnabled, Qr as useIsDocumentModelSelectionSettingsEnabled, Qt as addIsAnalyticsDatabaseWorkerEnabledEventHandler, R as useRevisionHistoryVisible, Ri as useIsExternalControlsEnabled, Rn as setCliVersion, Rr as useFileUploadOperationsChunkSize, Rt as addAllowListEventHandler, S as addSelectedTimelineItemEventHandler, Sa as isDocumentTypeSupported, Si as useVersion, Sn as addRenownUrlEventHandler, Sr as setSentryDsn, St as extractDriveIdFromSlug, T as useSelectedNode, Ta as setPHModal, Ti as addAllowedDocumentTypesEventHandler, Tn as addSentryDsnEventHandler, Tr as setStudioMode, Tt as extractNodeIdFromSlug, U as useDatabase, Ui as startDocumentChangesSubscription, Un as setFileUploadOperationsChunkSize, Ur as useIsAddPublicDrivesEnabled, Ut as addDisabledEditorsEventHandler, V as setReactorClient, Vi as viewFilterInputFromViewFilter, Vn as setDrivesPreserveStrategy, Vr as useIsAddDriveEnabled, Vt as addCliVersionEventHandler, W as useModelRegistry, Wi as subscriptionsUrlFromGraphqlUrl, Wn as setGaTrackingId, Wr as useIsAnalyticsDatabaseWorkerEnabled, Wt as addDrivesPreserveStrategyEventHandler, X as addPackageDiscoveryServiceEventHandler, Xi as MutateDocumentWithOperationsDocument, Xn as setIsAnalyticsEnabled, Xr as useIsDeletePublicDrivesEnabled, Xt as addIsAddLocalDrivesEnabledEventHandler, Y as useSyncList, Yi as stampAction, Yn as setIsAnalyticsDatabaseWorkerEnabled, Yr as useIsDeleteLocalDrivesEnabled, Yt as addIsAddDriveEnabledEventHandler, Z as setPackageDiscoveryService, Zi as ReactorOperationFieldsFragmentDoc, Zn as setIsAnalyticsExternalProcessorsEnabled, Zr as useIsDiffAnalyticsEnabled, Zt as addIsAddPublicDrivesEnabledEventHandler, _ as setPHToast, _a as moveNode$1, _i as useSentryDsn, _n as addLocalDrivesEnabledEventHandler, _r as setRenownChainId, _t as addDrivesEventHandler, a as ensurePHEventHandlers, aa as convertRemoteOperations, ai as useIsLocalDrivesEnabled, an as addIsDiffAnalyticsEnabledEventHandler, ar as setIsEditorDebugModeEnabled, at as useDropTarget, b as setSelectedTimelineRevision, ba as upgradeDocument, bi as useStudioMode, bn as addRenownChainIdEventHandler, br as setRequiresHardRefresh, bt as createUrlWithPreservedParams, c as packageFromDocumentModels, ca as screamingSnakeToCamel, ci as useIsSentryTracingEnabled, cn as addIsEditorDebugModeEnabledEventHandler, cr as setIsExternalProcessorsEnabled, ct as setSelectedDrive, d as commonGlobalEventHandlerFunctions, da as addFileWithProgress, di as useRenownAdapters, dn as addIsExternalProcessorsEnabledEventHandler, dr as setIsPublicDrivesEnabled, dt as useSelectedDriveId, ea as phDocumentFromGetDocument, ei as useIsEditorDebugModeEnabled, en as addIsAnalyticsExternalProcessorsEnabledEventHandler, er as setIsDeleteLocalDrivesEnabled, et as setGraphQLReactorClient, f as addVetraPackageManagerEventHandler, fa as addFolder, fi as useRenownChainId, fn as addIsExternalRelationalProcessorsEnabledEventHandler, fr as setIsRelationalProcessorsEnabled, ft as useSelectedDriveSafe, g as addToastEventHandler, ga as loadFile, gi as useRouterBasename, gn as addIsSentryTracingEnabledEventHandler, gr as setRenownAdapters, gt as setSelectedNode, h as useVetraPackages, ha as exportFile, hi as useRequiresHardRefresh, hn as addIsRelationalProcessorsEnabledEventHandler, hr as setLogLevel, ht as addSetSelectedNodeOnPopStateEventHandler, i as GraphQLReactorProvider, ia as buildPulledDocument, ii as useIsExternalRelationalProcessorsEnabled, in as addIsDeletePublicDrivesEnabledEventHandler, ir as setIsDriveAnalyticsEnabled, it as useDropNode, j as isFileNodeKind, ja as DocumentNotFoundError, ji as phDocumentEditorConfigHooks, jn as addVersionEventHandler, jr as useAnalyticsDatabaseName, jt as resolveUrlPathname, k as useFolderNodesInSelectedDrive, ka as usePHModal, ki as phAppConfigHooks, kn as addSwitchboardUrlEventHandler, kr as setWarnOutdatedApp, kt as makeDriveUrlComponent, l as addPHEventHandlers, la as addDocument, li as useLocalDrivesEnabled, ln as addIsEditorReadModeEnabledEventHandler, lr as setIsExternalRelationalProcessorsEnabled, lt as setSelectedDriveId, m as useVetraPackageManager, ma as deleteNode, mi as useRenownUrl, mn as addIsPublicDrivesEnabledEventHandler, mr as setLocalDrivesEnabled, mt as addSelectedNodeIdEventHandler, n as useDocumentModelModuleById, na as revisionMapFromRevisionsList, ni as useIsExternalPackagesEnabled, nn as addIsDeleteCloudDrivesEnabledEventHandler, nr as setIsDiffAnalyticsEnabled, nt as addDraggingNodeEventHandler, o as useSwitchboardClient, oa as extractRevisionMap, oi as useIsPublicDrivesEnabled, on as addIsDocumentModelSelectionSettingsEnabledEventHandler, or as setIsEditorReadModeEnabled, ot as addSelectedDriveIdEventHandler, p as setVetraPackageManager, pa as copyNode$1, pi as useRenownNetworkId, pn as addIsLocalDrivesEnabledEventHandler, pr as setIsSentryTracingEnabled, pt as addResetSelectedNodeEventHandler, q as useReactorClientModule, qi as subgraphUrlFromGraphqlUrl, qn as setIsAddLocalDrivesEnabled, qr as useIsCloudDrivesEnabled, qt as addGaTrackingIdEventHandler, r as useDocumentModelModules, ra as ConflictError, ri as useIsExternalProcessorsEnabled, rn as addIsDeleteLocalDrivesEnabledEventHandler, rr as setIsDocumentModelSelectionSettingsEnabled, rt as useDragNode, s as StaticPackageManager, sa as hasRevisionConflict, si as useIsRelationalProcessorsEnabled, sn as addIsDriveAnalyticsEnabledEventHandler, sr as setIsExternalPackagesEnabled, st as addSetSelectedDriveOnPopStateEventHandler, t as useDocumentOperations, ta as phDocumentFromMutation, ti as useIsEditorReadModeEnabled, tn as addIsCloudDrivesEnabledEventHandler, tr as setIsDeletePublicDrivesEnabled, tt as useGraphQLReactorClient, u as callEventHandlerRegisterFunctions, ua as addFile, ui as useLogLevel, un as addIsExternalPackagesEnabledEventHandler, ur as setIsLocalDrivesEnabled, ut as useSelectedDrive, v as usePHToast, va as renameDriveNode, vi as useSentryEnv, vn as addLogLevelEventHandler, vr as setRenownNetworkId, vt as setDrives, w as useSelectedTimelineItem, wa as closePHModal, wi as useWarnOutdatedApp, wn as addRouterBasenameEventHandler, wr as setSentryRelease, wt as extractNodeIdFromPath, x as useSelectedTimelineRevision, xa as getUserPermissions, xi as useSwitchboardUrl, xn as addRenownNetworkIdEventHandler, xr as setRouterBasename, xt as extractDriveIdFromPath, y as addSelectedTimelineRevisionEventHandler, ya as renameNode, yi as useSentryRelease, yn as addRenownAdaptersEventHandler, yr as setRenownUrl, yt as useDrives, z as addReactorClientEventHandler, zi as GraphQLReactorClient, zn as setDefaultDrivesUrl, zr as useGaTrackingId, zt as addAnalyticsDatabaseNameEventHandler } from "./document-operations-D0ePGjbp.js";
3
+ import { t as makePHEventFunctions } from "./make-ph-event-functions-DBq3iWYn.js";
4
+ import { a as setGlobal, i as getGlobal, n as getAnalyticsStore, r as clearGlobal, t as createAnalyticsStore } from "./store-DAJq6vSs.js";
3
5
  import { baseDocumentModels, baseDocumentModelsMap } from "./src/document-model.js";
4
- import { n as GetDocumentWithOperationsDocument, r as PropagationMode, t as createClient } from "./client-_Gh2Uf0E.js";
5
- import { A as useLoginStatus, C as RENOWN_CHAIN_ID, D as addRenownEventHandler, E as VERIFIABLE_CREDENTIAL_EIP712_TYPE, F as setLoading, I as useLoading, M as useUser, N as addLoadingEventHandler, O as setRenown, P as loading, S as ISSUER_TYPE, T as RENOWN_URL, _ as openRenown, a as RenownAuthButton, b as CREDENTIAL_TYPES, c as ChevronDownIcon, d as RenownLogo, f as SpinnerIcon, g as logout, h as login, i as initRenownCrypto, j as useRenown, k as useDid, l as CopyIcon, m as useRenownAuth, n as useRenownInit, o as RenownUserButton, p as UserIcon, r as initConnectCrypto, s as RenownLoginButton, t as Renown, u as DisconnectIcon, v as CREDENTIAL_SCHEMA_EIP712_TYPE, w as RENOWN_NETWORK_ID, x as DOMAIN_TYPE, y as CREDENTIAL_SUBJECT_TYPE } from "./renown-D-1c_Bvx.js";
6
- import { i as setPGliteDB, n as useRelationalQuery, r as useRelationalDb, t as createProcessorQuery } from "./relational-Dj06-YkI.js";
7
- import { i as trimTrailingSlash, n as getPackages, r as getPackagesByDocumentType, t as RegistryClient } from "./client-u13cr-Vg.js";
8
- import { logger } from "document-model";
9
- import { baseLoadFromInput, baseLoadFromInputVersioned, baseSaveToFileHandle, createPresignedHeader, createZip, documentModelDocumentType, generateId, replayDocumentVersioned, setName, validateInitialState, validateModules, validateStateSchemaName } from "@powerhousedao/shared/document-model";
10
- import { DriveDocumentSchema, addFolder as addFolder$1, copyNode, driveCreateDocument, generateNodesCopy, handleTargetNameCollisions, isFileNode, isFolderNode, moveNode, setAvailableOffline, setDriveIcon, setDriveName, setSharingType, updateNode } from "@powerhousedao/shared/document-drive";
11
- import { allPass, conditional, constant, filter, find, forEach, forEachObj, funnel, hasAtLeast, isArray, isDefined, isIncludedIn, isNot, isStrictEqual, isString, isTruthy, last, map, mapToObj, once, pipe, prop, split, unique } from "remeda";
12
- import { ChannelScheme, DocumentChangeType, DocumentChangeType as DocumentChangeType$1, DocumentIntegrityService, DriveCollectionId, DriveCollectionId as DriveCollectionId$1, DuplicateManifestError, DuplicateModuleError, GqlRequestChannel, InMemoryQueue, IntervalPollTimer, ModuleNotFoundError, PollBehavior, PropagationMode as PropagationMode$1, REACTOR_SCHEMA, REACTOR_SCHEMA as REACTOR_SCHEMA$1, ReactorBuilder, ReactorClientBuilder, RelationalDbProcessor, SyncOperationStatus, SyncStatus, driveIdFromUrl, isDriveAuthError, isDriveAuthError as isDriveAuthError$1, parseDriveUrl } from "@powerhousedao/reactor";
6
+ import { i as GetDocumentWithOperationsDocument, o as PropagationMode, t as createClient } from "./client-s_ISz_Zs.js";
7
+ import { a as useRenown, c as RENOWN_INITIAL_UNKNOWN, d as useRenownInitialUser, f as addLoadingEventHandler, h as useLoading, i as useLoginStatus, l as RenownInitialUserProvider, m as setLoading, n as setRenown, o as useUser, p as loading, r as useDid, s as RENOWN_INITIAL_ANONYMOUS, t as addRenownEventHandler, u as useRenownInitialAuth } from "./renown-BZabzj4l.js";
8
+ import { A as RENOWN_NETWORK_ID, C as openRenown, D as DOMAIN_TYPE, E as CREDENTIAL_TYPES, M as VERIFIABLE_CREDENTIAL_EIP712_TYPE, O as ISSUER_TYPE, S as logout, T as CREDENTIAL_SUBJECT_TYPE, _ as SpinnerIcon, a as useRenownInit, b as useRenownAuthAsync, c as initConnectCrypto, d as RenownUserButton, f as RenownLoginButton, g as RenownLogo, h as DisconnectIcon, i as Renown, j as RENOWN_URL, k as RENOWN_CHAIN_ID, l as initRenownCrypto, m as CopyIcon, n as RenownProvider, o as useRenownSessionCookie, p as ChevronDownIcon, r as RenownWalletProvider, s as useRenownSessionSynced, t as useRenownLoginMethods, u as RenownAuthButton, v as UserIcon, w as CREDENTIAL_SCHEMA_EIP712_TYPE, x as login, y as useRenownAuth } from "./renown-C7a1ygsj.js";
9
+ import { i as setPGliteDB, n as useRelationalQuery, r as useRelationalDb, t as createProcessorQuery } from "./relational-C_0GdGVN.js";
10
+ import { a as getPackagesForDocumentType, i as getPackagesByDocumentType, n as getPackagePage, o as trimTrailingSlash, r as getPackages, t as RegistryClient } from "./client-Zz_l9QzI.js";
11
+ import { validateInitialState, validateModules, validateStateSchemaName } from "@powerhousedao/shared/document-model";
12
+ import { DriveDocumentSchema, driveCreateDocument, isFileNode, setAvailableOffline, setDriveIcon, setDriveName, setSharingType } from "@powerhousedao/shared/document-drive";
13
+ import { allPass, filter, find, forEach, funnel, hasAtLeast, isArray, isDefined, isIncludedIn, isStrictEqual, isTruthy, last, map, mapToObj, once, pipe, prop, split, unique } from "remeda";
13
14
  import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
15
+ import { ChannelScheme, DocumentChangeType, DocumentChangeType as DocumentChangeType$1, DocumentIntegrityService, DriveCollectionId, DriveCollectionId as DriveCollectionId$1, GqlRequestChannel, InMemoryQueue, IntervalPollTimer, ModuleNotFoundError, PollBehavior, PropagationMode as PropagationMode$1, REACTOR_SCHEMA, REACTOR_SCHEMA as REACTOR_SCHEMA$1, ReactorBuilder, ReactorClientBuilder, RelationalDbProcessor, SyncOperationStatus, SyncStatus, driveIdFromUrl, isDriveAuthError, isDriveAuthError as isDriveAuthError$1, parseDriveUrl } from "@powerhousedao/reactor";
14
16
  import { z } from "zod";
15
- import slug from "slug";
16
17
  import normalizeException from "normalize-exception";
17
18
  import * as lzString from "lz-string";
18
19
  import { createAttachmentClient } from "@powerhousedao/reactor-attachments/client";
19
- //#region src/errors.ts
20
- var UnsupportedDocumentTypeError = class extends Error {
21
- constructor(documentType) {
22
- super(`Document type ${documentType} is not supported`);
23
- this.name = "UnsupportedDocumentTypeError";
24
- }
25
- static isError(error) {
26
- return Error.isError(error) && error.name === "UnsupportedDocumentTypeError";
27
- }
28
- };
29
- var DocumentModelNotFoundError = class extends Error {
30
- documentType;
31
- name = "DocumentModelNotFoundError";
32
- constructor(documentType) {
33
- super(`Document model module for type ${documentType} not found`);
34
- this.documentType = documentType;
35
- }
36
- static isError(error) {
37
- return Error.isError(error) && error.name === "DocumentModelNotFoundError";
38
- }
39
- };
40
- var DocumentTypeMismatchError = class extends Error {
41
- constructor(documentId, expectedType, actualType) {
42
- super(`Document ${documentId} is not of type ${expectedType}. Actual type: ${actualType}`);
43
- }
44
- };
45
- var NoSelectedDocumentError = class extends Error {
46
- constructor() {
47
- super("There is no selected document. Did you mean to call 'useSelectedDocumentSafe' instead?");
48
- }
49
- };
50
- //#endregion
51
- //#region src/utils/documents.ts
52
- function isDocumentTypeSupported(documentType, supportedDocuments) {
53
- if (!supportedDocuments?.length) return true;
54
- return supportedDocuments.some((pattern) => {
55
- if (pattern.endsWith("/*")) {
56
- const prefix = pattern.slice(0, -2);
57
- return documentType.startsWith(prefix + "/");
58
- }
59
- if (pattern.endsWith("*") && !pattern.endsWith("/*")) {
60
- const prefix = pattern.slice(0, -1);
61
- return documentType.startsWith(prefix);
62
- }
63
- return pattern === documentType;
64
- });
65
- }
66
- //#endregion
67
- //#region src/utils/user.ts
68
- function getUserPermissions() {
69
- const user = window.ph?.renown?.user;
70
- const allowList = window.ph?.allowList;
71
- if (!allowList) return {
72
- isAllowedToCreateDocuments: true,
73
- isAllowedToEditDocuments: true
74
- };
75
- return {
76
- isAllowedToCreateDocuments: allowList.includes(user?.address ?? ""),
77
- isAllowedToEditDocuments: allowList.includes(user?.address ?? "")
78
- };
79
- }
80
- //#endregion
81
- //#region src/actions/document.ts
82
- const BASE_STATE_KEYS = new Set(["auth"]);
83
- const NON_DOMAIN_SCOPES = new Set(["auth", "document"]);
84
- async function isDocumentInLocation(document, driveId, parentFolder) {
85
- const reactorClient = window.ph?.reactorClient;
86
- if (!reactorClient) return { isDuplicate: false };
87
- let drive;
88
- try {
89
- drive = await reactorClient.get(driveId);
90
- } catch {
91
- return { isDuplicate: false };
92
- }
93
- const nodeById = drive.state.global.nodes.find((node) => node.id === document.header.id);
94
- if (nodeById && nodeById.parentFolder === (parentFolder ?? null)) return {
95
- isDuplicate: true,
96
- duplicateType: "id",
97
- nodeId: nodeById.id
98
- };
99
- const nodeByNameAndType = drive.state.global.nodes.find((node) => isFileNode(node) && node.name === document.header.name && node.documentType === document.header.documentType && node.parentFolder === (parentFolder ?? null));
100
- if (nodeByNameAndType) return {
101
- isDuplicate: true,
102
- duplicateType: "name",
103
- nodeId: nodeByNameAndType.id
104
- };
105
- return { isDuplicate: false };
106
- }
107
- function getDocumentTypeIcon(document) {
108
- switch (document.header.documentType) {
109
- case "powerhouse/document-model": return "document-model";
110
- case "powerhouse/app": return "app";
111
- case "powerhouse/document-editor": return "editor";
112
- case "powerhouse/subgraph": return "subgraph";
113
- case "powerhouse/package": return "package";
114
- case "powerhouse/processor": {
115
- const processorType = document.state.global?.type;
116
- if (processorType === "analytics") return "analytics-processor";
117
- if (processorType === "relational") return "relational-processor";
118
- if (processorType === "codegen") return "codegen-processor";
119
- return;
120
- }
121
- default: return;
122
- }
123
- }
124
- async function downloadFile(document, fileName) {
125
- try {
126
- const data = await createZip(document);
127
- const blob = new Blob([new Uint8Array(data)], { type: "application/zip" });
128
- const link = window.document.createElement("a");
129
- link.style.display = "none";
130
- link.href = URL.createObjectURL(blob);
131
- link.download = fileName;
132
- window.document.body.appendChild(link);
133
- link.click();
134
- window.document.body.removeChild(link);
135
- } catch (e) {
136
- logger.error(e instanceof Error ? e.message : String(e));
137
- }
138
- }
139
- async function getDocumentExtension(document) {
140
- const documentType = document.header.documentType;
141
- let rawExtension;
142
- if (documentType === documentModelDocumentType) rawExtension = document.state.global?.extension;
143
- else {
144
- const reactorClient = window.ph?.reactorClient;
145
- if (reactorClient) {
146
- const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
147
- rawExtension = documentModelModules.find((m) => m.documentModel.global.id === documentType)?.utils.fileExtension;
148
- }
149
- }
150
- return (rawExtension ?? "").replace(/^\.+|\.+$/g, "");
151
- }
152
- /**
153
- * Fetches all operations for a document using cursor-based pagination.
154
- * The reactor client handles multi-scope cursors transparently via
155
- * composite cursors, so all scopes are fetched in a single paginated stream.
156
- */
157
- async function fetchDocumentOperations(reactorClient, document, pageSize = 100) {
158
- const scopes = Object.keys(document.state).filter((k) => !BASE_STATE_KEYS.has(k));
159
- const operations = {};
160
- for (const scope of scopes) operations[scope] = [];
161
- let cursor = "";
162
- do {
163
- const page = await reactorClient.getOperations(document.header.id, { scopes }, void 0, {
164
- cursor,
165
- limit: pageSize
166
- });
167
- for (const op of page.results) {
168
- const scope = op.action.scope ?? "global";
169
- if (operations[scope]) operations[scope].push(op);
170
- }
171
- cursor = page.nextCursor ?? "";
172
- } while (cursor);
173
- return operations;
174
- }
175
- function extractInitialState(documentScopeOps) {
176
- const upgradeOp = documentScopeOps.find((op) => op.action.type === "UPGRADE_DOCUMENT");
177
- if (!upgradeOp) throw new Error("No UPGRADE_DOCUMENT operation found — document is invalid");
178
- const input = upgradeOp.action.input;
179
- const initialState = input.initialState ?? input.state;
180
- if (!initialState) throw new Error("UPGRADE_DOCUMENT operation has no initialState — document is invalid");
181
- return initialState;
182
- }
183
- function filterDomainOperations(operations) {
184
- return Object.fromEntries(Object.entries(operations).filter(([scope]) => !NON_DOMAIN_SCOPES.has(scope)));
185
- }
186
- async function exportFile(document, suggestedName) {
187
- const reactorClient = window.ph?.reactorClient;
188
- if (!reactorClient) throw new Error("ReactorClient not initialized");
189
- const operations = await fetchDocumentOperations(reactorClient, document);
190
- const initialState = extractInitialState(operations["document"] ?? []);
191
- const documentWithOps = {
192
- ...document,
193
- operations,
194
- initialState
195
- };
196
- const extension = await getDocumentExtension(documentWithOps);
197
- const baseName = suggestedName || documentWithOps.header.name || "Untitled";
198
- const name = extension ? `${baseName}.${extension}.phd` : `${baseName}.phd`;
199
- if (!window.showSaveFilePicker) return await downloadFile(documentWithOps, name);
200
- try {
201
- const fileHandle = await window.showSaveFilePicker({ suggestedName: name });
202
- await baseSaveToFileHandle(documentWithOps, fileHandle);
203
- return fileHandle;
204
- } catch (e) {
205
- if (!(e instanceof DOMException && e.name === "AbortError")) throw e;
206
- }
207
- }
208
- /**
209
- * Loads a document file and replays it with version-aware reducers from the registry.
210
- * Falls back to single-version legacy replay when no upgrade manifest is registered for
211
- * the document type.
212
- */
213
- async function loadFile(path) {
214
- const baseDocument = await baseLoadFromInput(path, (state) => state, { checkHashes: true });
215
- const reactorClient = window.ph?.reactorClient;
216
- if (!reactorClient) throw new Error("ReactorClient not initialized");
217
- const documentType = baseDocument.header.documentType;
218
- const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
219
- const modulesForType = documentModelModules.filter((module) => module.documentModel.global.id === documentType);
220
- if (modulesForType.length === 0) throw new DocumentModelNotFoundError(documentType);
221
- const reducers = {};
222
- for (const module of modulesForType) reducers[module.version ?? 1] = module.reducer;
223
- const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
224
- let upgradeManifest;
225
- if (registry) try {
226
- upgradeManifest = registry.getUpgradeManifest(documentType);
227
- } catch {}
228
- return baseLoadFromInputVersioned(path, {
229
- reducers,
230
- upgradeManifest
231
- });
232
- }
233
- async function addDocument(driveId, name, documentType, parentFolder, document, id, preferredEditor) {
234
- const { isAllowedToCreateDocuments } = getUserPermissions();
235
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create documents");
236
- const reactorClient = window.ph?.reactorClient;
237
- if (!reactorClient) throw new Error("ReactorClient not initialized");
238
- const documentModelModule = await reactorClient.getDocumentModelModule(documentType);
239
- const newDocument = document ?? documentModelModule.utils.createDocument();
240
- newDocument.header.name = name;
241
- if (preferredEditor) newDocument.header.meta = {
242
- ...newDocument.header.meta,
243
- preferredEditor
244
- };
245
- let newDoc;
246
- try {
247
- newDoc = await reactorClient.drives.addFile(driveId, newDocument, parentFolder);
248
- } catch (e) {
249
- logger.error("Error adding document: @error", e);
250
- throw new Error("There was an error adding document", { cause: e });
251
- }
252
- return {
253
- id: newDoc.header.id,
254
- name: newDoc.header.name,
255
- documentType,
256
- parentFolder: parentFolder ?? null,
257
- kind: "file"
258
- };
259
- }
260
- async function addFile(file, driveId, name, parentFolder) {
261
- logger.verbose(`addFile(drive: ${driveId}, name: ${name}, folder: ${parentFolder})`);
262
- const { isAllowedToCreateDocuments } = getUserPermissions();
263
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create files");
264
- const document = await loadFile(file);
265
- let duplicateId = false;
266
- const reactorClient = window.ph?.reactorClient;
267
- if (!reactorClient) throw new Error("ReactorClient not initialized");
268
- try {
269
- await reactorClient.get(document.header.id);
270
- duplicateId = true;
271
- } catch {}
272
- const documentId = duplicateId ? generateId() : document.header.id;
273
- const header = createPresignedHeader(documentId, document.header.documentType);
274
- header.lastModifiedAtUtcIso = document.header.createdAtUtcIso;
275
- header.meta = document.header.meta;
276
- header.name = name || document.header.name;
277
- const initialDocument = {
278
- ...document,
279
- header,
280
- state: document.initialState,
281
- operations: Object.keys(document.operations).reduce((acc, key) => {
282
- acc[key] = [];
283
- return acc;
284
- }, {})
285
- };
286
- await addDocument(driveId, name || document.header.name, document.header.documentType, parentFolder, initialDocument, documentId, document.header.meta?.preferredEditor);
287
- await uploadOperations(documentId, filterDomainOperations(document.operations), queueOperations);
288
- }
289
- async function addFileWithProgress(file, driveId, name, parentFolder, onProgress, documentTypes, resolveConflict) {
290
- logger.verbose(`addFileWithProgress(drive: ${driveId}, name: ${name}, folder: ${parentFolder})`);
291
- const reactor = window.ph?.reactorClient;
292
- if (!reactor) return;
293
- const { isAllowedToCreateDocuments } = getUserPermissions();
294
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create files");
295
- try {
296
- onProgress?.({
297
- stage: "loading",
298
- progress: 0
299
- });
300
- let document;
301
- try {
302
- document = await loadFile(file);
303
- } catch (loadError) {
304
- const discoveryService = window.ph?.packageDiscoveryService;
305
- if (discoveryService && DocumentModelNotFoundError.isError(loadError)) {
306
- retryAfterDiscovery(discoveryService, loadError.documentType, file, driveId, name, parentFolder, onProgress, documentTypes, resolveConflict);
307
- return;
308
- }
309
- throw loadError;
310
- }
311
- const duplicateCheck = await isDocumentInLocation(document, driveId, parentFolder);
312
- if (duplicateCheck.isDuplicate && !resolveConflict) {
313
- onProgress?.({
314
- stage: "conflict",
315
- progress: 0,
316
- duplicateType: duplicateCheck.duplicateType
317
- });
318
- return;
319
- }
320
- const documentType = getDocumentTypeIcon(document);
321
- if (documentType) onProgress?.({
322
- stage: "loading",
323
- progress: 10,
324
- documentType
325
- });
326
- else onProgress?.({
327
- stage: "loading",
328
- progress: 10
329
- });
330
- if (!isDocumentTypeSupported(document.header.documentType, documentTypes)) {
331
- onProgress?.({
332
- stage: "unsupported-document-type",
333
- progress: 100,
334
- error: `Document type ${document.header.documentType} is not supported`
335
- });
336
- throw new UnsupportedDocumentTypeError(document.header.documentType);
337
- }
338
- await reactor.getDocumentModelModule(document.header.documentType);
339
- onProgress?.({
340
- stage: "initializing",
341
- progress: 10
342
- });
343
- let duplicateId = false;
344
- try {
345
- await reactor.get(document.header.id);
346
- duplicateId = true;
347
- } catch {}
348
- const documentId = duplicateId ? generateId() : document.header.id;
349
- const header = createPresignedHeader(documentId, document.header.documentType);
350
- header.lastModifiedAtUtcIso = document.header.createdAtUtcIso;
351
- header.meta = document.header.meta;
352
- header.name = name || document.header.name;
353
- const initialDocument = {
354
- ...document,
355
- header,
356
- state: document.initialState,
357
- operations: Object.keys(document.operations).reduce((acc, key) => {
358
- acc[key] = [];
359
- return acc;
360
- }, {})
361
- };
362
- const fileNode = await addDocument(driveId, name || document.header.name, document.header.documentType, parentFolder, initialDocument, documentId, document.header.meta?.preferredEditor);
363
- if (!fileNode) throw new Error("There was an error adding file");
364
- onProgress?.({
365
- stage: "initializing",
366
- progress: 20
367
- });
368
- await reactor.get(documentId);
369
- console.log("Document created, starting upload of operations");
370
- await uploadOperations(documentId, filterDomainOperations(document.operations), queueOperations, { onProgress: (uploadProgress) => {
371
- if (uploadProgress.totalOperations && uploadProgress.uploadedOperations !== void 0) {
372
- const uploadPercent = uploadProgress.totalOperations > 0 ? uploadProgress.uploadedOperations / uploadProgress.totalOperations : 0;
373
- const overallProgress = 20 + Math.round(uploadPercent * 80);
374
- onProgress?.({
375
- stage: "uploading",
376
- progress: overallProgress,
377
- totalOperations: uploadProgress.totalOperations,
378
- uploadedOperations: uploadProgress.uploadedOperations
379
- });
380
- }
381
- } });
382
- onProgress?.({
383
- stage: "complete",
384
- progress: 100,
385
- fileNode
386
- });
387
- return fileNode;
388
- } catch (error) {
389
- if (!UnsupportedDocumentTypeError.isError(error)) {
390
- const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
391
- onProgress?.({
392
- stage: "failed",
393
- progress: 100,
394
- error: errorMessage
395
- });
396
- }
397
- throw error;
398
- }
399
- }
400
- async function retryAfterDiscovery(discoveryService, documentType, file, driveId, name, parentFolder, onProgress, documentTypes, resolveConflict) {
401
- if (!discoveryService) return;
402
- try {
403
- await discoveryService.load(documentType);
404
- } catch {
405
- onProgress?.({
406
- stage: "unsupported-document-type",
407
- progress: 100,
408
- error: `Document type ${documentType} is not supported`
409
- });
410
- return;
411
- }
412
- await addFileWithProgress(file, driveId, name, parentFolder, onProgress, documentTypes, resolveConflict);
413
- }
414
- async function addFolder(driveId, name, parentFolder) {
415
- const { isAllowedToCreateDocuments } = getUserPermissions();
416
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create folders");
417
- const reactorClient = window.ph?.reactorClient;
418
- if (!reactorClient) throw new Error("ReactorClient not initialized");
419
- await reactorClient.get(driveId);
420
- const folderId = generateId();
421
- const node = (await reactorClient.execute(driveId, "main", [addFolder$1({
422
- id: folderId,
423
- name,
424
- parentFolder
425
- })])).state.global.nodes.find((node) => node.id === folderId);
426
- if (!node || !isFolderNode(node)) throw new Error("There was an error adding folder");
427
- return node;
428
- }
429
- async function deleteNode(driveId, nodeId) {
430
- const { isAllowedToCreateDocuments } = getUserPermissions();
431
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to delete documents");
432
- const reactorClient = window.ph?.reactorClient;
433
- if (!reactorClient) throw new Error("ReactorClient not initialized");
434
- await reactorClient.drives.removeNode(driveId, nodeId);
435
- }
436
- async function renameNode(driveId, nodeId, name) {
437
- const { isAllowedToCreateDocuments } = getUserPermissions();
438
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to rename documents");
439
- const reactorClient = window.ph?.reactorClient;
440
- if (!reactorClient) throw new Error("ReactorClient not initialized");
441
- if ((await reactorClient.execute(nodeId, "main", [setName({ name })])).header.name !== name) throw new Error("There was an error renaming the node");
442
- const node = (await reactorClient.execute(driveId, "main", [updateNode({
443
- id: nodeId,
444
- name
445
- })])).state.global.nodes.find((n) => n.id === nodeId);
446
- if (!node) throw new Error("There was an error renaming node in the drive");
447
- return node;
448
- }
449
- async function renameDriveNode(driveId, nodeId, name) {
450
- const { isAllowedToCreateDocuments } = getUserPermissions();
451
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to rename documents");
452
- const reactorClient = window.ph?.reactorClient;
453
- if (!reactorClient) throw new Error("ReactorClient not initialized");
454
- if ((await reactorClient.execute(nodeId, "main", [setName({ name })])).header.name !== name) throw new Error("There was an error renaming the node");
455
- await reactorClient.execute(driveId, "main", [updateNode({
456
- id: nodeId,
457
- name
458
- })]);
459
- return (await reactorClient.get(driveId)).state.global.nodes.find((n) => n.id === nodeId);
460
- }
461
- async function moveNodeById(args) {
462
- const { driveId, srcId, targetId } = args;
463
- if (!driveId || !srcId) return;
464
- const { isAllowedToCreateDocuments } = getUserPermissions();
465
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to move documents");
466
- const reactorClient = window.ph?.reactorClient;
467
- if (!reactorClient) throw new Error("ReactorClient not initialized");
468
- const targetParentFolder = conditional(targetId, [isNot(isDefined), constant(void 0)], [isStrictEqual(driveId), constant(void 0)], constant(targetId));
469
- if (isStrictEqual(targetParentFolder, srcId)) return;
470
- return await reactorClient.execute(driveId, "main", [moveNode({
471
- srcFolder: srcId,
472
- targetParentFolder
473
- })]);
474
- }
475
- async function moveNode$1(driveId, src, target) {
476
- const { isAllowedToCreateDocuments } = getUserPermissions();
477
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to move documents");
478
- const reactorClient = window.ph?.reactorClient;
479
- if (!reactorClient) throw new Error("ReactorClient not initialized");
480
- return await reactorClient.execute(driveId, "main", [moveNode({
481
- srcFolder: src.id,
482
- targetParentFolder: target?.id
483
- })]);
484
- }
485
- /**
486
- * Duplicates a document under a new id using version-aware replay.
487
- * Falls back gracefully when no upgrade manifest is registered for the document type.
488
- */
489
- async function _duplicateDocument(reactor, document, newId = generateId()) {
490
- const documentType = document.header.documentType;
491
- const { results: allModules } = await reactor.getDocumentModelModules();
492
- const modulesForType = allModules.filter((m) => m.documentModel.global.id === documentType);
493
- const reducers = {};
494
- for (const m of modulesForType) reducers[m.version ?? 1] = m.reducer;
495
- if (Object.keys(reducers).length === 0) throw new Error(`Document model module not found for type: ${documentType}`);
496
- const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
497
- let upgradeManifest;
498
- if (registry) try {
499
- upgradeManifest = registry.getUpgradeManifest(documentType);
500
- } catch {}
501
- const config = {
502
- reducers,
503
- upgradeManifest
504
- };
505
- const header = createPresignedHeader(newId, documentType);
506
- return replayDocumentVersioned(document.initialState, document.operations, config, header);
507
- }
508
- async function copyNode$1(driveId, src, target) {
509
- const reactor = window.ph?.reactorClient;
510
- if (!reactor) return;
511
- const { isAllowedToCreateDocuments } = getUserPermissions();
512
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to copy documents");
513
- const drive = await reactor.get(driveId);
514
- const copyNodesInput = generateNodesCopy({
515
- srcId: src.id,
516
- targetParentFolder: target?.id,
517
- targetName: src.name
518
- }, () => generateId(), drive.state.global.nodes);
519
- const resolvedNamesMap = /* @__PURE__ */ new Map();
520
- for (const copyNodeInput of copyNodesInput) {
521
- const node = drive.state.global.nodes.find((n) => n.id === copyNodeInput.srcId);
522
- if (node) {
523
- const resolvedName = handleTargetNameCollisions({
524
- nodes: drive.state.global.nodes,
525
- srcName: copyNodeInput.targetName || node.name,
526
- srcKind: isFileNode(node) ? "file" : "folder",
527
- targetParentFolder: copyNodeInput.targetParentFolder || null
528
- });
529
- resolvedNamesMap.set(copyNodeInput.targetId, resolvedName);
530
- }
531
- }
532
- const fileNodesToCopy = copyNodesInput.filter((copyNodeInput) => {
533
- const node = drive.state.global.nodes.find((node) => node.id === copyNodeInput.srcId);
534
- return node !== void 0 && isFileNode(node);
535
- });
536
- for (const fileNodeToCopy of fileNodesToCopy) try {
537
- const duplicatedDocument = await _duplicateDocument(reactor, await reactor.get(fileNodeToCopy.srcId), fileNodeToCopy.targetId);
538
- const resolvedName = resolvedNamesMap.get(fileNodeToCopy.targetId);
539
- if (resolvedName) duplicatedDocument.header.name = resolvedName;
540
- await reactor.drives.addFile(driveId, duplicatedDocument, target?.id);
541
- } catch (e) {
542
- logger.error(`Error copying document ${fileNodeToCopy.srcId}: ${String(e)}`);
543
- }
544
- return await queueActions(drive, copyNodesInput.map((copyNodeInput) => copyNode(copyNodeInput)));
545
- }
546
- //#endregion
547
- //#region src/hooks/modals.ts
548
- const modalEventFunctions = makePHEventFunctions("modal");
549
- /** Returns the current modal */
550
- const usePHModal = modalEventFunctions.useValue;
551
- /** Sets the current modal */
552
- const setPHModal = modalEventFunctions.setValue;
553
- /** Adds an event handler for the modal */
554
- const addModalEventHandler = modalEventFunctions.addEventHandler;
555
- /** Shows a modal */
556
- function showPHModal(modal) {
557
- setPHModal(modal);
558
- }
559
- /** Closes the current modal */
560
- function closePHModal() {
561
- setPHModal(void 0);
562
- }
563
- /** Shows the create document modal */
564
- function showCreateDocumentModal(documentType) {
565
- setPHModal({
566
- type: "createDocument",
567
- documentType
568
- });
569
- }
570
- /** Shows the delete node modal */
571
- function showDeleteNodeModal(nodeOrId) {
572
- setPHModal({
573
- type: "deleteItem",
574
- id: typeof nodeOrId === "string" ? nodeOrId : nodeOrId.id
575
- });
576
- }
577
- //#endregion
578
20
  //#region src/actions/drive.ts
579
21
  const DEFAULT_INITIAL_SYNC_TIMEOUT_MS = 3e4;
580
22
  const inFlightRemoteRegistrations = /* @__PURE__ */ new Map();
@@ -634,7 +76,7 @@ async function addDrive(input, preferredEditor) {
634
76
  return await reactorClient.create(driveDoc);
635
77
  }
636
78
  async function addRemoteDrive(url, driveId, options) {
637
- const reactorClient = window.ph?.reactorClient;
79
+ const reactorClient = window.ph?.reactorClientModule?.client;
638
80
  if (!reactorClient) throw new Error("ReactorClient not initialized");
639
81
  const sync = window.ph?.reactorClientModule?.reactorModule?.syncModule?.syncManager;
640
82
  if (!sync) throw new Error("Sync not initialized");
@@ -681,7 +123,7 @@ async function deleteDrive(driveId) {
681
123
  async function renameDrive(driveId, name) {
682
124
  const { isAllowedToCreateDocuments } = getUserPermissions();
683
125
  if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to rename drives");
684
- const reactorClient = window.ph?.reactorClient;
126
+ const reactorClient = window.ph?.reactorClientModule?.client;
685
127
  if (!reactorClient) throw new Error("ReactorClient not initialized");
686
128
  return await reactorClient.rename(driveId, name);
687
129
  }
@@ -993,876 +435,6 @@ async function reactorGraphqlMutateDocument(documentIdentifier, ...actions) {
993
435
  });
994
436
  }
995
437
  //#endregion
996
- //#region src/hooks/config/editor.ts
997
- const isExternalControlsEnabledEventFunctions = makePHEventFunctions("isExternalControlsEnabled");
998
- /** Sets whether external controls are enabled for a given editor. */
999
- const setIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.setValue;
1000
- /** Gets whether external controls are enabled for a given editor. */
1001
- const useIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.useValue;
1002
- /** Adds an event handler for when the external controls enabled state changes. */
1003
- const addIsExternalControlsEnabledEventHandler = isExternalControlsEnabledEventFunctions.addEventHandler;
1004
- const isDragAndDropEnabledEventFunctions = makePHEventFunctions("isDragAndDropEnabled");
1005
- /** Sets whether drag and drop is enabled for a given app. */
1006
- const setIsDragAndDropEnabled = isDragAndDropEnabledEventFunctions.setValue;
1007
- /** Gets whether drag and drop is enabled for a given app. */
1008
- const useIsDragAndDropEnabled = isDragAndDropEnabledEventFunctions.useValue;
1009
- /** Adds an event handler for when the drag and drop enabled state changes. */
1010
- const addIsDragAndDropEnabledEventHandler = isDragAndDropEnabledEventFunctions.addEventHandler;
1011
- const allowedDocumentTypesEventFunctions = makePHEventFunctions("allowedDocumentTypes");
1012
- /** Sets the allowed document types for a given app. */
1013
- const setAllowedDocumentTypes = allowedDocumentTypesEventFunctions.setValue;
1014
- /** Defines the document types a drive supports.
1015
- *
1016
- * Defaults to all of the document types registered in the reactor.
1017
- */
1018
- function useAllowedDocumentTypes() {
1019
- return allowedDocumentTypesEventFunctions.useValue();
1020
- }
1021
- /** Adds an event handler for when the allowed document types for a given app changes. */
1022
- const addAllowedDocumentTypesEventHandler = allowedDocumentTypesEventFunctions.addEventHandler;
1023
- const phAppConfigSetters = {
1024
- allowedDocumentTypes: setAllowedDocumentTypes,
1025
- isDragAndDropEnabled: setIsDragAndDropEnabled
1026
- };
1027
- const phDocumentEditorConfigSetters = { isExternalControlsEnabled: setIsExternalControlsEnabled };
1028
- const phAppConfigHooks = {
1029
- allowedDocumentTypes: useAllowedDocumentTypes,
1030
- isDragAndDropEnabled: useIsDragAndDropEnabled
1031
- };
1032
- const phDocumentEditorConfigHooks = { isExternalControlsEnabled: useIsExternalControlsEnabled };
1033
- //#endregion
1034
- //#region src/hooks/config/connect.ts
1035
- const { useValue: useRouterBasename, setValue: setRouterBasename, addEventHandler: addRouterBasenameEventHandler } = makePHEventFunctions("routerBasename");
1036
- const { useValue: useVersion, setValue: setVersion, addEventHandler: addVersionEventHandler } = makePHEventFunctions("version");
1037
- const { useValue: useRequiresHardRefresh, setValue: setRequiresHardRefresh, addEventHandler: addRequiresHardRefreshEventHandler } = makePHEventFunctions("requiresHardRefresh");
1038
- const { useValue: useWarnOutdatedApp, setValue: setWarnOutdatedApp, addEventHandler: addWarnOutdatedAppEventHandler } = makePHEventFunctions("warnOutdatedApp");
1039
- const { useValue: useStudioMode, setValue: setStudioMode, addEventHandler: addStudioModeEventHandler } = makePHEventFunctions("studioMode");
1040
- const { useValue: useBasePath, setValue: setBasePath, addEventHandler: addBasePathEventHandler } = makePHEventFunctions("basePath");
1041
- const { useValue: useVersionCheckInterval, setValue: setVersionCheckInterval, addEventHandler: addVersionCheckIntervalEventHandler } = makePHEventFunctions("versionCheckInterval");
1042
- const { useValue: useCliVersion, setValue: setCliVersion, addEventHandler: addCliVersionEventHandler } = makePHEventFunctions("cliVersion");
1043
- const { useValue: useFileUploadOperationsChunkSize, setValue: setFileUploadOperationsChunkSize, addEventHandler: addFileUploadOperationsChunkSizeEventHandler } = makePHEventFunctions("fileUploadOperationsChunkSize");
1044
- const { useValue: useIsDocumentModelSelectionSettingsEnabled, setValue: setIsDocumentModelSelectionSettingsEnabled, addEventHandler: addIsDocumentModelSelectionSettingsEnabledEventHandler } = makePHEventFunctions("isDocumentModelSelectionSettingsEnabled");
1045
- const { useValue: useGaTrackingId, setValue: setGaTrackingId, addEventHandler: addGaTrackingIdEventHandler } = makePHEventFunctions("gaTrackingId");
1046
- const { useValue: useDefaultDrivesUrl, setValue: setDefaultDrivesUrl, addEventHandler: addDefaultDrivesUrlEventHandler } = makePHEventFunctions("defaultDrivesUrl");
1047
- const { useValue: useDrivesPreserveStrategy, setValue: setDrivesPreserveStrategy, addEventHandler: addDrivesPreserveStrategyEventHandler } = makePHEventFunctions("drivesPreserveStrategy");
1048
- const { useValue: useIsLocalDrivesEnabled, setValue: setIsLocalDrivesEnabled, addEventHandler: addIsLocalDrivesEnabledEventHandler } = makePHEventFunctions("isLocalDrivesEnabled");
1049
- const { useValue: useIsAddDriveEnabled, setValue: setIsAddDriveEnabled, addEventHandler: addIsAddDriveEnabledEventHandler } = makePHEventFunctions("isAddDriveEnabled");
1050
- const { useValue: useIsPublicDrivesEnabled, setValue: setIsPublicDrivesEnabled, addEventHandler: addIsPublicDrivesEnabledEventHandler } = makePHEventFunctions("isPublicDrivesEnabled");
1051
- const { useValue: useIsAddPublicDrivesEnabled, setValue: setIsAddPublicDrivesEnabled, addEventHandler: addIsAddPublicDrivesEnabledEventHandler } = makePHEventFunctions("isAddPublicDrivesEnabled");
1052
- const { useValue: useIsDeletePublicDrivesEnabled, setValue: setIsDeletePublicDrivesEnabled, addEventHandler: addIsDeletePublicDrivesEnabledEventHandler } = makePHEventFunctions("isDeletePublicDrivesEnabled");
1053
- const { useValue: useIsCloudDrivesEnabled, setValue: setIsCloudDrivesEnabled, addEventHandler: addIsCloudDrivesEnabledEventHandler } = makePHEventFunctions("isCloudDrivesEnabled");
1054
- const { useValue: useIsAddCloudDrivesEnabled, setValue: setIsAddCloudDrivesEnabled, addEventHandler: addIsAddCloudDrivesEnabledEventHandler } = makePHEventFunctions("isAddCloudDrivesEnabled");
1055
- const { useValue: useIsDeleteCloudDrivesEnabled, setValue: setIsDeleteCloudDrivesEnabled, addEventHandler: addIsDeleteCloudDrivesEnabledEventHandler } = makePHEventFunctions("isDeleteCloudDrivesEnabled");
1056
- const { useValue: useLocalDrivesEnabled, setValue: setLocalDrivesEnabled, addEventHandler: addLocalDrivesEnabledEventHandler } = makePHEventFunctions("isLocalDrivesEnabled");
1057
- const { useValue: useIsAddLocalDrivesEnabled, setValue: setIsAddLocalDrivesEnabled, addEventHandler: addIsAddLocalDrivesEnabledEventHandler } = makePHEventFunctions("isAddLocalDrivesEnabled");
1058
- const { useValue: useIsDeleteLocalDrivesEnabled, setValue: setIsDeleteLocalDrivesEnabled, addEventHandler: addIsDeleteLocalDrivesEnabledEventHandler } = makePHEventFunctions("isDeleteLocalDrivesEnabled");
1059
- const { useValue: useIsEditorDebugModeEnabled, setValue: setIsEditorDebugModeEnabled, addEventHandler: addIsEditorDebugModeEnabledEventHandler } = makePHEventFunctions("isEditorDebugModeEnabled");
1060
- const { useValue: useIsEditorReadModeEnabled, setValue: setIsEditorReadModeEnabled, addEventHandler: addIsEditorReadModeEnabledEventHandler } = makePHEventFunctions("isEditorReadModeEnabled");
1061
- const { useValue: useIsAnalyticsDatabaseWorkerEnabled, setValue: setIsAnalyticsDatabaseWorkerEnabled, addEventHandler: addIsAnalyticsDatabaseWorkerEnabledEventHandler } = makePHEventFunctions("isAnalyticsDatabaseWorkerEnabled");
1062
- const { useValue: useIsDiffAnalyticsEnabled, setValue: setIsDiffAnalyticsEnabled, addEventHandler: addIsDiffAnalyticsEnabledEventHandler } = makePHEventFunctions("isDiffAnalyticsEnabled");
1063
- const { useValue: useIsDriveAnalyticsEnabled, setValue: setIsDriveAnalyticsEnabled, addEventHandler: addIsDriveAnalyticsEnabledEventHandler } = makePHEventFunctions("isDriveAnalyticsEnabled");
1064
- const { useValue: useRenownUrl, setValue: setRenownUrl, addEventHandler: addRenownUrlEventHandler } = makePHEventFunctions("renownUrl");
1065
- const { useValue: useRenownNetworkId, setValue: setRenownNetworkId, addEventHandler: addRenownNetworkIdEventHandler } = makePHEventFunctions("renownNetworkId");
1066
- const { useValue: useRenownChainId, setValue: setRenownChainId, addEventHandler: addRenownChainIdEventHandler } = makePHEventFunctions("renownChainId");
1067
- const { useValue: useSentryRelease, setValue: setSentryRelease, addEventHandler: addSentryReleaseEventHandler } = makePHEventFunctions("sentryRelease");
1068
- const { useValue: useSentryDsn, setValue: setSentryDsn, addEventHandler: addSentryDsnEventHandler } = makePHEventFunctions("sentryDsn");
1069
- const { useValue: useSentryEnv, setValue: setSentryEnv, addEventHandler: addSentryEnvEventHandler } = makePHEventFunctions("sentryEnv");
1070
- const { useValue: useIsSentryTracingEnabled, setValue: setIsSentryTracingEnabled, addEventHandler: addIsSentryTracingEnabledEventHandler } = makePHEventFunctions("isSentryTracingEnabled");
1071
- const { useValue: useIsExternalProcessorsEnabled, setValue: setIsExternalProcessorsEnabled, addEventHandler: addIsExternalProcessorsEnabledEventHandler } = makePHEventFunctions("isExternalProcessorsEnabled");
1072
- const { useValue: useIsExternalPackagesEnabled, setValue: setIsExternalPackagesEnabled, addEventHandler: addIsExternalPackagesEnabledEventHandler } = makePHEventFunctions("isExternalPackagesEnabled");
1073
- const enabledEditorsEventFunctions = makePHEventFunctions("enabledEditors");
1074
- /** Sets the enabled editors for Connect. */
1075
- const setEnabledEditors = enabledEditorsEventFunctions.setValue;
1076
- /** Gets the enabled editors for Connect. */
1077
- const useEnabledEditors = enabledEditorsEventFunctions.useValue;
1078
- /** Adds an event handler for when the enabled editors for Connect changes. */
1079
- const addEnabledEditorsEventHandler = enabledEditorsEventFunctions.addEventHandler;
1080
- const disabledEditorsEventFunctions = makePHEventFunctions("disabledEditors");
1081
- /** Sets the disabled editors for Connect. */
1082
- const setDisabledEditors = disabledEditorsEventFunctions.setValue;
1083
- /** Gets the disabled editors for Connect. */
1084
- const useDisabledEditors = disabledEditorsEventFunctions.useValue;
1085
- /** Adds an event handler for when the disabled editors for Connect changes. */
1086
- const addDisabledEditorsEventHandler = disabledEditorsEventFunctions.addEventHandler;
1087
- const isRelationalProcessorsEnabled = makePHEventFunctions("isRelationalProcessorsEnabled");
1088
- /** Sets the isRelationalProcessorsEnabled for Connect. */
1089
- const setIsRelationalProcessorsEnabled = isRelationalProcessorsEnabled.setValue;
1090
- /** Gets the isRelationalProcessorsEnabled for Connect. */
1091
- const useIsRelationalProcessorsEnabled = isRelationalProcessorsEnabled.useValue;
1092
- /** Adds an event handler for when the isRelationalProcessorsEnabled for Connect changes. */
1093
- const addIsRelationalProcessorsEnabledEventHandler = isRelationalProcessorsEnabled.addEventHandler;
1094
- const isExternalRelationalProcessorsEnabled = makePHEventFunctions("isExternalRelationalProcessorsEnabled");
1095
- /** Sets the isExternalRelationalProcessorsEnabled for Connect. */
1096
- const setIsExternalRelationalProcessorsEnabled = isExternalRelationalProcessorsEnabled.setValue;
1097
- /** Gets the isExternalRelationalProcessorsEnabled for Connect. */
1098
- const useIsExternalRelationalProcessorsEnabled = isExternalRelationalProcessorsEnabled.useValue;
1099
- /** Adds an event handler for when the isExternalRelationalProcessorsEnabled for Connect changes. */
1100
- const addIsExternalRelationalProcessorsEnabledEventHandler = isExternalRelationalProcessorsEnabled.addEventHandler;
1101
- const isAnalyticsEnabledEventFunctions = makePHEventFunctions("isAnalyticsEnabled");
1102
- /** Sets the isAnalyticsEnabled for Connect. */
1103
- const setIsAnalyticsEnabled = isAnalyticsEnabledEventFunctions.setValue;
1104
- /** Gets the isAnalyticsEnabled for Connect. */
1105
- const useIsAnalyticsEnabled = isAnalyticsEnabledEventFunctions.useValue;
1106
- /** Adds an event handler for when the isAnalyticsEnabled for Connect changes. */
1107
- const addIsAnalyticsEnabledEventHandler = isAnalyticsEnabledEventFunctions.addEventHandler;
1108
- const isAnalyticsExternalProcessorsEnabled = makePHEventFunctions("isAnalyticsExternalProcessorsEnabled");
1109
- /** Sets the isAnalyticsExternalProcessorsEnabled for Connect. */
1110
- const setIsAnalyticsExternalProcessorsEnabled = isAnalyticsExternalProcessorsEnabled.setValue;
1111
- /** Gets the isAnalyticsExternalProcessorsEnabled for Connect. */
1112
- const useIsAnalyticsExternalProcessorsEnabled = isAnalyticsExternalProcessorsEnabled.useValue;
1113
- /** Adds an event handler for when the isAnalyticsExternalProcessorsEnabled for Connect changes. */
1114
- const addIsAnalyticsExternalProcessorsEnabledEventHandler = isAnalyticsExternalProcessorsEnabled.addEventHandler;
1115
- const analyticsDatabaseNameEventFunctions = makePHEventFunctions("analyticsDatabaseName");
1116
- /** Sets the analytics database name for Connect. */
1117
- const setAnalyticsDatabaseName = analyticsDatabaseNameEventFunctions.setValue;
1118
- /** Gets the analytics database name for Connect. */
1119
- const useAnalyticsDatabaseName = analyticsDatabaseNameEventFunctions.useValue;
1120
- /** Adds an event handler for when the analytics database name for Connect changes. */
1121
- const addAnalyticsDatabaseNameEventHandler = analyticsDatabaseNameEventFunctions.addEventHandler;
1122
- const logLevelEventFunctions = makePHEventFunctions("logLevel");
1123
- /** Sets the log level for Connect. */
1124
- const setLogLevel = logLevelEventFunctions.setValue;
1125
- /** Gets the log level for Connect. */
1126
- const useLogLevel = logLevelEventFunctions.useValue;
1127
- /** Adds an event handler for when the log level for Connect changes. */
1128
- const addLogLevelEventHandler = logLevelEventFunctions.addEventHandler;
1129
- const allowListEventFunctions = makePHEventFunctions("allowList");
1130
- /** Sets the allow list for Connect. */
1131
- const setAllowList = allowListEventFunctions.setValue;
1132
- /** Gets the allow list for Connect. */
1133
- const useAllowList = allowListEventFunctions.useValue;
1134
- /** Adds an event handler for when the allow list for Connect changes. */
1135
- const addAllowListEventHandler = allowListEventFunctions.addEventHandler;
1136
- const nonUserConfigSetters = {
1137
- routerBasename: setRouterBasename,
1138
- version: setVersion,
1139
- requiresHardRefresh: setRequiresHardRefresh,
1140
- warnOutdatedApp: setWarnOutdatedApp,
1141
- studioMode: setStudioMode,
1142
- basePath: setBasePath,
1143
- versionCheckInterval: setVersionCheckInterval,
1144
- cliVersion: setCliVersion,
1145
- fileUploadOperationsChunkSize: setFileUploadOperationsChunkSize,
1146
- isDocumentModelSelectionSettingsEnabled: setIsDocumentModelSelectionSettingsEnabled,
1147
- gaTrackingId: setGaTrackingId,
1148
- defaultDrivesUrl: setDefaultDrivesUrl,
1149
- drivesPreserveStrategy: setDrivesPreserveStrategy,
1150
- isLocalDrivesEnabled: setIsLocalDrivesEnabled,
1151
- isAddDriveEnabled: setIsAddDriveEnabled,
1152
- isPublicDrivesEnabled: setIsPublicDrivesEnabled,
1153
- isAddPublicDrivesEnabled: setIsAddPublicDrivesEnabled,
1154
- isDeletePublicDrivesEnabled: setIsDeletePublicDrivesEnabled,
1155
- isCloudDrivesEnabled: setIsCloudDrivesEnabled,
1156
- isAddCloudDrivesEnabled: setIsAddCloudDrivesEnabled,
1157
- isDeleteCloudDrivesEnabled: setIsDeleteCloudDrivesEnabled,
1158
- isAddLocalDrivesEnabled: setIsAddLocalDrivesEnabled,
1159
- isDeleteLocalDrivesEnabled: setIsDeleteLocalDrivesEnabled,
1160
- isEditorDebugModeEnabled: setIsEditorDebugModeEnabled,
1161
- isEditorReadModeEnabled: setIsEditorReadModeEnabled,
1162
- isRelationalProcessorsEnabled: setIsRelationalProcessorsEnabled,
1163
- isExternalRelationalProcessorsEnabled: setIsExternalRelationalProcessorsEnabled,
1164
- isAnalyticsEnabled: setIsAnalyticsEnabled,
1165
- analyticsDatabaseName: setAnalyticsDatabaseName,
1166
- isAnalyticsExternalProcessorsEnabled: setIsAnalyticsExternalProcessorsEnabled,
1167
- isAnalyticsDatabaseWorkerEnabled: setIsAnalyticsDatabaseWorkerEnabled,
1168
- isDiffAnalyticsEnabled: setIsDiffAnalyticsEnabled,
1169
- isDriveAnalyticsEnabled: setIsDriveAnalyticsEnabled,
1170
- renownUrl: setRenownUrl,
1171
- renownNetworkId: setRenownNetworkId,
1172
- renownChainId: setRenownChainId,
1173
- sentryRelease: setSentryRelease,
1174
- sentryDsn: setSentryDsn,
1175
- sentryEnv: setSentryEnv,
1176
- isSentryTracingEnabled: setIsSentryTracingEnabled,
1177
- isExternalProcessorsEnabled: setIsExternalProcessorsEnabled,
1178
- isExternalPackagesEnabled: setIsExternalPackagesEnabled,
1179
- allowList: setAllowList,
1180
- logLevel: setLogLevel,
1181
- disabledEditors: setDisabledEditors,
1182
- enabledEditors: setEnabledEditors
1183
- };
1184
- const phGlobalConfigSetters = {
1185
- ...phAppConfigSetters,
1186
- ...phDocumentEditorConfigSetters,
1187
- ...nonUserConfigSetters
1188
- };
1189
- const nonUserConfigHooks = {
1190
- routerBasename: useRouterBasename,
1191
- version: useVersion,
1192
- requiresHardRefresh: useRequiresHardRefresh,
1193
- warnOutdatedApp: useWarnOutdatedApp,
1194
- studioMode: useStudioMode,
1195
- basePath: useBasePath,
1196
- versionCheckInterval: useVersionCheckInterval,
1197
- cliVersion: useCliVersion,
1198
- fileUploadOperationsChunkSize: useFileUploadOperationsChunkSize,
1199
- isDocumentModelSelectionSettingsEnabled: useIsDocumentModelSelectionSettingsEnabled,
1200
- gaTrackingId: useGaTrackingId,
1201
- defaultDrivesUrl: useDefaultDrivesUrl,
1202
- drivesPreserveStrategy: useDrivesPreserveStrategy,
1203
- isAddDriveEnabled: useIsAddDriveEnabled,
1204
- isPublicDrivesEnabled: useIsPublicDrivesEnabled,
1205
- isAddPublicDrivesEnabled: useIsAddPublicDrivesEnabled,
1206
- isDeletePublicDrivesEnabled: useIsDeletePublicDrivesEnabled,
1207
- isCloudDrivesEnabled: useIsCloudDrivesEnabled,
1208
- isAddCloudDrivesEnabled: useIsAddCloudDrivesEnabled,
1209
- isDeleteCloudDrivesEnabled: useIsDeleteCloudDrivesEnabled,
1210
- isLocalDrivesEnabled: useIsLocalDrivesEnabled,
1211
- isAddLocalDrivesEnabled: useIsAddLocalDrivesEnabled,
1212
- isDeleteLocalDrivesEnabled: useIsDeleteLocalDrivesEnabled,
1213
- isEditorDebugModeEnabled: useIsEditorDebugModeEnabled,
1214
- isEditorReadModeEnabled: useIsEditorReadModeEnabled,
1215
- isAnalyticsDatabaseWorkerEnabled: useIsAnalyticsDatabaseWorkerEnabled,
1216
- isDiffAnalyticsEnabled: useIsDiffAnalyticsEnabled,
1217
- isDriveAnalyticsEnabled: useIsDriveAnalyticsEnabled,
1218
- renownUrl: useRenownUrl,
1219
- renownNetworkId: useRenownNetworkId,
1220
- renownChainId: useRenownChainId,
1221
- sentryRelease: useSentryRelease,
1222
- sentryDsn: useSentryDsn,
1223
- sentryEnv: useSentryEnv,
1224
- isSentryTracingEnabled: useIsSentryTracingEnabled,
1225
- isExternalProcessorsEnabled: useIsExternalProcessorsEnabled,
1226
- isExternalPackagesEnabled: useIsExternalPackagesEnabled,
1227
- allowList: useAllowList,
1228
- isAnalyticsEnabled: useIsAnalyticsEnabled,
1229
- isAnalyticsExternalProcessorsEnabled: useIsAnalyticsExternalProcessorsEnabled,
1230
- isRelationalProcessorsEnabled: useIsRelationalProcessorsEnabled,
1231
- isExternalRelationalProcessorsEnabled: useIsExternalRelationalProcessorsEnabled,
1232
- analyticsDatabaseName: useAnalyticsDatabaseName,
1233
- logLevel: useLogLevel,
1234
- disabledEditors: useDisabledEditors,
1235
- enabledEditors: useEnabledEditors
1236
- };
1237
- const phGlobalConfigHooks = {
1238
- ...phAppConfigHooks,
1239
- ...phDocumentEditorConfigHooks,
1240
- ...nonUserConfigHooks
1241
- };
1242
- //#endregion
1243
- //#region src/hooks/attachment-service.ts
1244
- const attachmentServiceEventFunctions = makePHEventFunctions("attachmentService");
1245
- /** Returns the attachment service from window.ph */
1246
- const useAttachmentService = attachmentServiceEventFunctions.useValue;
1247
- /** Sets the attachment service on window.ph */
1248
- const setAttachmentService = attachmentServiceEventFunctions.setValue;
1249
- /** Registers the attachmentService window event handler */
1250
- const addAttachmentServiceEventHandler = attachmentServiceEventFunctions.addEventHandler;
1251
- //#endregion
1252
- //#region src/hooks/features.ts
1253
- const featuresEventFunctions = makePHEventFunctions("features");
1254
- const useFeatures = featuresEventFunctions.useValue;
1255
- const setFeatures = featuresEventFunctions.setValue;
1256
- const addFeaturesEventHandler = featuresEventFunctions.addEventHandler;
1257
- //#endregion
1258
- //#region src/utils/url.ts
1259
- function resolveUrlPathname(path) {
1260
- return new URL(path.replace(/^\/+/, ""), window.location.origin + (window.ph?.basePath ?? "/")).pathname;
1261
- }
1262
- /** Returns the current path without the base path */
1263
- function getPathWithoutBase(path) {
1264
- const basePath = window.ph?.basePath ?? "/";
1265
- return path.replace(basePath, basePath.endsWith("/") ? "/" : "");
1266
- }
1267
- /** Makes a URL component for a drive. */
1268
- function makeDriveUrlComponent(drive) {
1269
- if (!drive) return "";
1270
- return `/d/${slug(drive.header.slug)}`;
1271
- }
1272
- /** Makes a URL component for a node. */
1273
- function makeNodeSlug(node) {
1274
- if (!node) return "";
1275
- const nodeName = node.name;
1276
- if (!nodeName) return slug(node.id);
1277
- return slug(`${nodeName}-${node.id}`);
1278
- }
1279
- /** Extracts the node slug from a path.
1280
- *
1281
- * The path is expected to be in the format `/d/<drive-slug>/<node-slug>`.
1282
- */
1283
- function extractNodeSlugFromPath(path) {
1284
- const currentPath = getPathWithoutBase(path);
1285
- return /^\/d\/[^/]+\/([^/]+)$/.exec(currentPath)?.[1];
1286
- }
1287
- /** Finds a UUID in a string, used for extracting node ids from node slugs in the URL. */
1288
- function findUuid(input) {
1289
- if (!input) return void 0;
1290
- return /\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b/.exec(input)?.[0];
1291
- }
1292
- function extractNodeIdFromSlug(nodeSlug) {
1293
- return findUuid(nodeSlug);
1294
- }
1295
- function extractNodeIdFromPath(path) {
1296
- return extractNodeIdFromSlug(extractNodeSlugFromPath(path));
1297
- }
1298
- /** Extracts the drive slug from a path.
1299
- * Used for extracting drive ids from drive slugs in the URL.
1300
- * Expects the path to be in the format `/d/<drive-slug>`.
1301
- */
1302
- function extractDriveSlugFromPath(path) {
1303
- const currentPath = getPathWithoutBase(path);
1304
- return /^\/d\/([^/]+)/.exec(currentPath)?.[1] ?? "";
1305
- }
1306
- function extractDriveIdFromSlug(driveSlug) {
1307
- return findUuid(driveSlug);
1308
- }
1309
- function extractDriveIdFromPath(path) {
1310
- return extractDriveIdFromSlug(extractDriveSlugFromPath(path));
1311
- }
1312
- /**
1313
- * Creates a URL string with the given pathname while preserving existing query parameters.
1314
- */
1315
- function createUrlWithPreservedParams(pathname) {
1316
- const search = window.location.search;
1317
- return search ? `${pathname}${search}` : pathname;
1318
- }
1319
- //#endregion
1320
- //#region src/hooks/drives.ts
1321
- const drivesEventFunctions = makePHEventFunctions("drives");
1322
- /** Returns all of the drives in the reactor */
1323
- const useDrives = drivesEventFunctions.useValue;
1324
- /** Sets the drives in the reactor */
1325
- const setDrives = drivesEventFunctions.setValue;
1326
- /** Adds an event handler for the drives */
1327
- const addDrivesEventHandler = drivesEventFunctions.addEventHandler;
1328
- //#endregion
1329
- //#region src/hooks/set-selected-node.ts
1330
- const selectedNodeIdEventFunctions = makePHEventFunctions("selectedNodeId");
1331
- const useSelectedNodeId = selectedNodeIdEventFunctions.useValue;
1332
- const setSelectedNodeId = selectedNodeIdEventFunctions.setValue;
1333
- const addSelectedNodeIdEventHandler = selectedNodeIdEventFunctions.addEventHandler;
1334
- /** Sets the selected node (file or folder). */
1335
- function setSelectedNode(nodeOrNodeSlug) {
1336
- const nodeSlug = typeof nodeOrNodeSlug === "string" ? nodeOrNodeSlug : makeNodeSlug(nodeOrNodeSlug);
1337
- setSelectedNodeId(extractNodeIdFromSlug(nodeSlug));
1338
- const driveSlugFromPath = extractDriveSlugFromPath(window.location.pathname);
1339
- if (!driveSlugFromPath) return;
1340
- if (!nodeSlug) {
1341
- const pathname = resolveUrlPathname(`/d/${driveSlugFromPath}`);
1342
- if (pathname === window.location.pathname) return;
1343
- window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
1344
- return;
1345
- }
1346
- const pathname = resolveUrlPathname(`/d/${driveSlugFromPath}/${nodeSlug}`);
1347
- if (pathname === window.location.pathname) return;
1348
- window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
1349
- }
1350
- function addResetSelectedNodeEventHandler() {
1351
- window.addEventListener("ph:selectedDriveIdUpdated", () => {
1352
- setSelectedNodeId(void 0);
1353
- });
1354
- }
1355
- function addSetSelectedNodeOnPopStateEventHandler() {
1356
- window.addEventListener("popstate", () => {
1357
- const pathname = window.location.pathname;
1358
- const nodeSlug = extractNodeSlugFromPath(pathname);
1359
- if (extractNodeIdFromSlug(nodeSlug) !== window.ph?.selectedNodeId) setSelectedNode(nodeSlug);
1360
- });
1361
- }
1362
- //#endregion
1363
- //#region src/hooks/selected-drive.ts
1364
- const selectedDriveIdEventFunctions = makePHEventFunctions("selectedDriveId");
1365
- /** Returns the selected drive id */
1366
- const useSelectedDriveId = selectedDriveIdEventFunctions.useValue;
1367
- /** Sets the selected drive id */
1368
- const setSelectedDriveId = selectedDriveIdEventFunctions.setValue;
1369
- /** Adds an event handler for the selected drive id */
1370
- const addSelectedDriveIdEventHandler = selectedDriveIdEventFunctions.addEventHandler;
1371
- /** Returns the selected drive */
1372
- function useSelectedDrive() {
1373
- const drive = useSelectedDriveSafe();
1374
- if (!drive[0]) throw new Error("There is no drive selected. Did you mean to call 'useSelectedDriveSafe'?");
1375
- return drive;
1376
- }
1377
- /** Returns the selected drive, or undefined if no drive is selected */
1378
- function useSelectedDriveSafe() {
1379
- const selectedDriveId = useSelectedDriveId();
1380
- const selectedDrive = useDrives()?.find((drive) => drive.header.id === selectedDriveId);
1381
- const [drive, dispatch] = useDispatch(selectedDrive);
1382
- if (!selectedDrive) return [void 0, void 0];
1383
- return [drive, dispatch];
1384
- }
1385
- function setSelectedDrive(driveOrDriveSlug) {
1386
- const driveSlug = typeof driveOrDriveSlug === "string" ? driveOrDriveSlug : driveOrDriveSlug?.header.slug;
1387
- const drives = window.ph?.drives;
1388
- const driveId = (typeof driveOrDriveSlug === "object" && driveOrDriveSlug !== null ? driveOrDriveSlug : drives?.find((d) => d.header.slug === driveSlug))?.header.id;
1389
- if (!driveId && driveSlug && extractDriveSlugFromPath(window.location.pathname) === driveSlug) {
1390
- if (window.ph?.selectedDriveId) setSelectedDriveId(void 0);
1391
- deferDriveSelection(driveSlug);
1392
- return;
1393
- }
1394
- cancelPendingDriveSelection();
1395
- setSelectedDriveId(driveId);
1396
- if (!driveId) {
1397
- const pathname = resolveUrlPathname("/");
1398
- if (pathname === window.location.pathname) return;
1399
- window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
1400
- return;
1401
- }
1402
- const pathname = resolveUrlPathname(`/d/${driveSlug}`);
1403
- if (pathname === window.location.pathname) return;
1404
- window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
1405
- }
1406
- const DEFERRED_DRIVE_TICK_MS = 2e3;
1407
- const DEFERRED_DRIVE_MAX_WAIT_MS = 15e3;
1408
- function isInitialSyncInFlight() {
1409
- const remotes = window.ph?.reactorClientModule?.reactorModule?.syncModule?.syncManager?.list();
1410
- if (!remotes?.length) return false;
1411
- return remotes.some((remote) => {
1412
- try {
1413
- const snapshot = remote.channel.getConnectionState();
1414
- return snapshot.receivingPages || !snapshot.lastSuccessUtcMs && snapshot.state !== "error";
1415
- } catch {
1416
- return false;
1417
- }
1418
- });
1419
- }
1420
- let pendingHandler;
1421
- let pendingTimeout;
1422
- function cancelPendingDriveSelection() {
1423
- if (pendingHandler) {
1424
- window.removeEventListener("ph:drivesUpdated", pendingHandler);
1425
- pendingHandler = void 0;
1426
- }
1427
- if (pendingTimeout) {
1428
- clearTimeout(pendingTimeout);
1429
- pendingTimeout = void 0;
1430
- }
1431
- }
1432
- function deferDriveSelection(driveSlug) {
1433
- cancelPendingDriveSelection();
1434
- const nodeSlug = extractNodeSlugFromPath(window.location.pathname);
1435
- const handler = () => {
1436
- if (!window.ph?.drives?.find((d) => d.header.slug === driveSlug)) return;
1437
- cancelPendingDriveSelection();
1438
- setSelectedDrive(driveSlug);
1439
- setSelectedNode(nodeSlug);
1440
- };
1441
- pendingHandler = handler;
1442
- window.addEventListener("ph:drivesUpdated", handler);
1443
- const deadline = Date.now() + DEFERRED_DRIVE_MAX_WAIT_MS;
1444
- const scheduleTick = () => {
1445
- pendingTimeout = setTimeout(() => {
1446
- if (Date.now() < deadline && isInitialSyncInFlight()) {
1447
- scheduleTick();
1448
- return;
1449
- }
1450
- cancelPendingDriveSelection();
1451
- const pathname = resolveUrlPathname("/");
1452
- if (pathname === window.location.pathname) return;
1453
- window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
1454
- }, DEFERRED_DRIVE_TICK_MS);
1455
- };
1456
- scheduleTick();
1457
- }
1458
- function addSetSelectedDriveOnPopStateEventHandler() {
1459
- window.addEventListener("popstate", () => {
1460
- const pathname = window.location.pathname;
1461
- const driveId = extractDriveIdFromPath(pathname);
1462
- if (driveId !== window.ph?.selectedDriveId) setSelectedDrive(driveId);
1463
- });
1464
- }
1465
- //#endregion
1466
- //#region src/hooks/use-drop-target.ts
1467
- function useDropTarget() {
1468
- const [isDropTarget, setIsDropTarget] = useState(false);
1469
- const isDragAndDropEnabled = useIsDragAndDropEnabled();
1470
- const targetSetter = funnel(() => setIsDropTarget(true), {
1471
- triggerAt: "start",
1472
- minQuietPeriodMs: 100
1473
- });
1474
- const targetUnsetter = funnel(() => setIsDropTarget(false), {
1475
- triggerAt: "start",
1476
- minQuietPeriodMs: 100
1477
- });
1478
- function setTarget() {
1479
- if (!isDragAndDropEnabled) return;
1480
- targetUnsetter.cancel();
1481
- targetSetter.call();
1482
- }
1483
- function unsetTarget() {
1484
- if (!isDragAndDropEnabled) return;
1485
- targetSetter.cancel();
1486
- targetUnsetter.call();
1487
- }
1488
- return {
1489
- isDropTarget,
1490
- setTarget,
1491
- unsetTarget
1492
- };
1493
- }
1494
- //#endregion
1495
- //#region src/hooks/node-drag-and-drop.ts
1496
- const draggingNodeEventFunctions = makePHEventFunctions("draggingNode");
1497
- const useDraggingNode = draggingNodeEventFunctions.useValue;
1498
- const setDraggingNode = draggingNodeEventFunctions.setValue;
1499
- const addDraggingNodeEventHandler = draggingNodeEventFunctions.addEventHandler;
1500
- const draggingNodeSetter = funnel((node) => setDraggingNode(node), {
1501
- reducer: (_, newNode) => newNode,
1502
- triggerAt: "start",
1503
- minQuietPeriodMs: 100
1504
- });
1505
- const draggingNodeUnsetter = funnel(() => setDraggingNode(void 0), {
1506
- triggerAt: "start",
1507
- minQuietPeriodMs: 100
1508
- });
1509
- function setDragging(node) {
1510
- draggingNodeUnsetter.cancel();
1511
- draggingNodeSetter.call(node);
1512
- }
1513
- function unsetDragging() {
1514
- draggingNodeSetter.cancel();
1515
- draggingNodeUnsetter.call();
1516
- }
1517
- const isNodeDrag = (params) => conditional(params, [({ srcId }) => isNot(isTruthy)(srcId), constant(false)], [({ driveId }) => isNot(isTruthy)(driveId), constant(false)], [({ driveId, srcId }) => isStrictEqual(driveId, srcId), constant(false)], constant(true));
1518
- function useDragNode(args) {
1519
- const { srcId, parentId } = args;
1520
- const driveId = useSelectedDriveId();
1521
- const draggingNodeId = useDraggingNode()?.srcId;
1522
- const params = {
1523
- driveId,
1524
- srcId,
1525
- parentId
1526
- };
1527
- const draggable = isNodeDrag(params);
1528
- const isDragging = allPass({
1529
- srcId,
1530
- draggingNodeId
1531
- }, [
1532
- () => draggable,
1533
- ({ srcId }) => isString(srcId),
1534
- ({ draggingNodeId }) => isString(draggingNodeId),
1535
- ({ srcId, draggingNodeId }) => isStrictEqual(srcId, draggingNodeId)
1536
- ]);
1537
- const onDragStart = () => {
1538
- if (!draggable) return;
1539
- setDragging(params);
1540
- };
1541
- const onDragEnd = () => {
1542
- if (!draggable) return;
1543
- unsetDragging();
1544
- };
1545
- return {
1546
- isDragging,
1547
- draggable,
1548
- onDragStart,
1549
- onDragEnd
1550
- };
1551
- }
1552
- const isNodeDrop = (params) => conditional(params, [({ srcId }) => isNot(isTruthy)(srcId), constant(false)], [({ driveId }) => isNot(isDefined)(driveId), constant(false)], [({ srcId, targetId }) => isStrictEqual(srcId, targetId), constant(false)], [({ driveId, parentId, targetId }) => isNot(isTruthy)(parentId) && isStrictEqual(targetId, driveId), constant(false)], [({ targetId, parentId }) => isStrictEqual(targetId, parentId), constant(false)], constant(true));
1553
- function useDropNode(targetId) {
1554
- const driveId = useSelectedDriveId();
1555
- const { srcId, parentId } = useDraggingNode() ?? {};
1556
- const { isDropTarget, setTarget, unsetTarget } = useDropTarget();
1557
- const params = {
1558
- driveId,
1559
- parentId,
1560
- targetId,
1561
- srcId
1562
- };
1563
- function handleNodeDrop(event, cb) {
1564
- if (!isNodeDrop(params)) return;
1565
- event.preventDefault();
1566
- event.stopPropagation();
1567
- cb?.();
1568
- }
1569
- const onDragEnter = (event) => handleNodeDrop(event);
1570
- const onDragOver = (event) => handleNodeDrop(event, once(setTarget));
1571
- const onDragLeave = (event) => handleNodeDrop(event, once(unsetTarget));
1572
- const onDrop = (event) => handleNodeDrop(event, once(() => {
1573
- unsetDragging();
1574
- unsetTarget();
1575
- moveNodeById(params).catch(console.error);
1576
- }));
1577
- return {
1578
- isDropTarget,
1579
- onDragEnter,
1580
- onDragOver,
1581
- onDragLeave,
1582
- onDrop
1583
- };
1584
- }
1585
- //#endregion
1586
- //#region src/hooks/graphql-reactor-client.ts
1587
- const graphQLReactorClientEventFunctions = makePHEventFunctions("reactorGraphQLClient");
1588
- const useGraphQLReactorClient = graphQLReactorClientEventFunctions.useValue;
1589
- const setGraphQLReactorClient = graphQLReactorClientEventFunctions.setValue;
1590
- const addGraphQLReactorClientEventHandler = graphQLReactorClientEventFunctions.addEventHandler;
1591
- //#endregion
1592
- //#region src/hooks/package-discovery.ts
1593
- const packageDiscoveryFunctions = makePHEventFunctions("packageDiscoveryService");
1594
- const usePackageDiscoveryService = packageDiscoveryFunctions.useValue;
1595
- const setPackageDiscoveryService = packageDiscoveryFunctions.setValue;
1596
- const addPackageDiscoveryServiceEventHandler = packageDiscoveryFunctions.addEventHandler;
1597
- //#endregion
1598
- //#region src/hooks/reactor.ts
1599
- const reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
1600
- const reactorClientEventFunctions = makePHEventFunctions("reactorClient");
1601
- /** Returns the reactor client module (in-process or worker-backed) */
1602
- const useReactorClientModule = reactorClientModuleEventFunctions.useValue;
1603
- /** Sets the reactor client module */
1604
- const setReactorClientModule = reactorClientModuleEventFunctions.setValue;
1605
- /** Adds an event handler for the reactor client module */
1606
- const addReactorClientModuleEventHandler = reactorClientModuleEventFunctions.addEventHandler;
1607
- /** Returns the reactor client */
1608
- const useReactorClient = reactorClientEventFunctions.useValue;
1609
- /** Sets the reactor client */
1610
- const setReactorClient = reactorClientEventFunctions.setValue;
1611
- /** Adds an event handler for the reactor client */
1612
- const addReactorClientEventHandler = reactorClientEventFunctions.addEventHandler;
1613
- const useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager;
1614
- const useSyncList = () => {
1615
- return useSync()?.list() ?? [];
1616
- };
1617
- const useModelRegistry = () => useReactorClientModule()?.reactorModule?.documentModelRegistry;
1618
- const useDatabase = () => {
1619
- const module = useReactorClientModule();
1620
- return module?.kind === "browser" ? module.reactorModule?.database : void 0;
1621
- };
1622
- const usePGlite = () => {
1623
- const module = useReactorClientModule();
1624
- return module?.kind === "browser" ? module.reactorModule?.pg : void 0;
1625
- };
1626
- //#endregion
1627
- //#region src/hooks/revision-history.ts
1628
- const revisionHistoryEventFunctions = makePHEventFunctions("revisionHistoryVisible");
1629
- /** Returns whether revision history is visible */
1630
- const useRevisionHistoryVisible = revisionHistoryEventFunctions.useValue;
1631
- /** Sets revision history visibility */
1632
- const setRevisionHistoryVisible = revisionHistoryEventFunctions.setValue;
1633
- /** Adds event handler for revision history visibility */
1634
- const addRevisionHistoryVisibleEventHandler = revisionHistoryEventFunctions.addEventHandler;
1635
- /** Shows the revision history */
1636
- function showRevisionHistory() {
1637
- setRevisionHistoryVisible(true);
1638
- }
1639
- /** Hides the revision history */
1640
- function hideRevisionHistory() {
1641
- setRevisionHistoryVisible(false);
1642
- }
1643
- //#endregion
1644
- //#region src/utils/nodes.ts
1645
- /** Sorts nodes by name. */
1646
- function sortNodesByName(nodes) {
1647
- return nodes.toSorted((a, b) => a.name.localeCompare(b.name));
1648
- }
1649
- /** Returns whether a node is a file. */
1650
- function isFileNodeKind(node) {
1651
- if (!node) return false;
1652
- return node.kind.toUpperCase() === "FILE";
1653
- }
1654
- /** Returns whether a node is a folder. */
1655
- function isFolderNodeKind(node) {
1656
- if (!node) return false;
1657
- return node.kind.toUpperCase() === "FOLDER";
1658
- }
1659
- //#endregion
1660
- //#region src/hooks/items-in-selected-drive.ts
1661
- /** Returns the nodes in the selected drive. */
1662
- function useNodesInSelectedDrive() {
1663
- const [selectedDrive] = useSelectedDriveSafe();
1664
- return selectedDrive?.state.global.nodes;
1665
- }
1666
- /** Returns the file nodes in the selected drive. */
1667
- function useFileNodesInSelectedDrive() {
1668
- return useNodesInSelectedDrive()?.filter((n) => isFileNodeKind(n));
1669
- }
1670
- /** Returns the folder nodes in the selected drive. */
1671
- function useFolderNodesInSelectedDrive() {
1672
- return useNodesInSelectedDrive()?.filter((n) => isFolderNodeKind(n));
1673
- }
1674
- /** Returns the documents in the selected drive. */
1675
- function useDocumentsInSelectedDrive() {
1676
- const fileNodeIds = useFileNodesInSelectedDrive()?.map((node) => node.id);
1677
- return useDocumentsByIds(fileNodeIds);
1678
- }
1679
- /** Returns the document types supported by the selected drive, as defined by the document model documents present in the drive */
1680
- function useDocumentTypesInSelectedDrive() {
1681
- return (useDocumentsInSelectedDrive()?.filter(isDocumentModelDocument))?.map((doc) => doc.state.global.id);
1682
- }
1683
- function isDocumentModelDocument(document) {
1684
- return document.header.documentType === "powerhouse/document-model";
1685
- }
1686
- //#endregion
1687
- //#region src/hooks/selected-node.ts
1688
- /** Returns the selected node. */
1689
- function useSelectedNode() {
1690
- const selectedNodeId = useSelectedNodeId();
1691
- return useNodesInSelectedDrive()?.find((n) => n.id === selectedNodeId);
1692
- }
1693
- //#endregion
1694
- //#region src/hooks/selected-timeline-item.ts
1695
- const selectedTimelineItemEventFunctions = makePHEventFunctions("selectedTimelineItem");
1696
- /** Returns the selected timeline item */
1697
- const useSelectedTimelineItem = selectedTimelineItemEventFunctions.useValue;
1698
- /** Sets the selected timeline item */
1699
- const setSelectedTimelineItem = selectedTimelineItemEventFunctions.setValue;
1700
- /** Adds event handler for selected timeline item */
1701
- const addSelectedTimelineItemEventHandler = selectedTimelineItemEventFunctions.addEventHandler;
1702
- //#endregion
1703
- //#region src/hooks/timeline-revision.ts
1704
- const selectedTimelineRevisionEventFunctions = makePHEventFunctions("selectedTimelineRevision");
1705
- /** Returns the selected timeline revision. */
1706
- const useSelectedTimelineRevision = selectedTimelineRevisionEventFunctions.useValue;
1707
- /** Sets the selected timeline revision. */
1708
- const setSelectedTimelineRevision = selectedTimelineRevisionEventFunctions.setValue;
1709
- /** Adds an event handler for the selected timeline revision. */
1710
- const addSelectedTimelineRevisionEventHandler = selectedTimelineRevisionEventFunctions.addEventHandler;
1711
- //#endregion
1712
- //#region src/hooks/toast.ts
1713
- const toastEventFunctions = makePHEventFunctions("toast");
1714
- /** Returns the toast function */
1715
- const usePHToast = toastEventFunctions.useValue;
1716
- /** Sets the toast function */
1717
- const setPHToast = toastEventFunctions.setValue;
1718
- /** Adds an event handler for the toast */
1719
- const addToastEventHandler = toastEventFunctions.addEventHandler;
1720
- //#endregion
1721
- //#region src/hooks/vetra-packages.ts
1722
- const vetraPackageManagerFunctions = makePHEventFunctions("vetraPackageManager");
1723
- const useVetraPackageManager = vetraPackageManagerFunctions.useValue;
1724
- /** Returns all of the Vetra packages loaded by the Connect instance */
1725
- const useVetraPackages = () => {
1726
- const packageManager = useVetraPackageManager();
1727
- return useSyncExternalStore((cb) => packageManager ? packageManager.subscribe(cb) : () => {}, () => packageManager?.packages ?? []);
1728
- };
1729
- /** Adds the Vetra package manager event handler */
1730
- const addVetraPackageManagerEventHandler = vetraPackageManagerFunctions.addEventHandler;
1731
- /** Sets the Vetra package manager and registers its packages */
1732
- function setVetraPackageManager(packageManager) {
1733
- vetraPackageManagerFunctions.setValue(packageManager);
1734
- updateReactorClientDocumentModels(packageManager.packages);
1735
- updateReactorClientUpgradeManifests(packageManager.packages);
1736
- packageManager.subscribe(({ packages }) => {
1737
- updateReactorClientDocumentModels(packages);
1738
- updateReactorClientUpgradeManifests(packages);
1739
- });
1740
- }
1741
- function updateReactorClientDocumentModels(packages) {
1742
- const documentModelModules = packages.flatMap((pkg) => pkg.documentModels);
1743
- const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
1744
- if (!registry || documentModelModules.length === 0) return;
1745
- const results = registry.registerModules(...documentModelModules);
1746
- const duplicates = [];
1747
- for (const result of results) if (result.status === "error") if (DuplicateModuleError.isError(result.error)) duplicates.push(result);
1748
- else console.error("Failed to register document model module:", result.error);
1749
- if (duplicates.length > 0) {
1750
- const duplicateTypes = duplicates.map((r) => r.item.documentModel.global.id);
1751
- registry.unregisterModules(...duplicateTypes);
1752
- registry.registerModules(...duplicates.map((r) => r.item));
1753
- }
1754
- }
1755
- function updateReactorClientUpgradeManifests(packages) {
1756
- const upgradeManifests = packages.flatMap((pkg) => pkg.upgradeManifests).filter((u) => u !== void 0);
1757
- const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
1758
- if (!registry || upgradeManifests.length === 0) return;
1759
- const results = registry.registerUpgradeManifests(...upgradeManifests);
1760
- const duplicates = [];
1761
- for (const result of results) if (result.status === "error") if (DuplicateManifestError.isError(result.error)) duplicates.push(result);
1762
- else console.error("Failed to register upgrade manifest:", result.error);
1763
- if (duplicates.length > 0) {
1764
- const duplicateTypes = duplicates.map((r) => r.item.documentType).filter((t) => !!t);
1765
- registry.unregisterUpgradeManifests(...duplicateTypes);
1766
- registry.registerUpgradeManifests(...duplicates.map((r) => r.item));
1767
- }
1768
- }
1769
- //#endregion
1770
- //#region src/hooks/add-ph-event-handlers.ts
1771
- const commonGlobalEventHandlerFunctions = {
1772
- loading: addLoadingEventHandler,
1773
- drives: addDrivesEventHandler,
1774
- selectedDriveId: () => {
1775
- addSelectedDriveIdEventHandler();
1776
- addSetSelectedDriveOnPopStateEventHandler();
1777
- addResetSelectedNodeEventHandler();
1778
- },
1779
- selectedNodeId: () => {
1780
- addSelectedNodeIdEventHandler();
1781
- addSetSelectedNodeOnPopStateEventHandler();
1782
- },
1783
- documentCache: addDocumentCacheEventHandler,
1784
- reactorGraphQLClient: addGraphQLReactorClientEventHandler,
1785
- draggingNode: addDraggingNodeEventHandler
1786
- };
1787
- const phGlobalEventHandlerRegisterFunctions = {
1788
- ...commonGlobalEventHandlerFunctions,
1789
- reactorClientModule: addReactorClientModuleEventHandler,
1790
- reactorClient: addReactorClientEventHandler,
1791
- attachmentService: addAttachmentServiceEventHandler,
1792
- features: addFeaturesEventHandler,
1793
- modal: addModalEventHandler,
1794
- renown: addRenownEventHandler,
1795
- vetraPackageManager: addVetraPackageManagerEventHandler,
1796
- packageDiscoveryService: addPackageDiscoveryServiceEventHandler,
1797
- selectedTimelineRevision: addSelectedTimelineRevisionEventHandler,
1798
- revisionHistoryVisible: addRevisionHistoryVisibleEventHandler,
1799
- selectedTimelineItem: addSelectedTimelineItemEventHandler,
1800
- routerBasename: addRouterBasenameEventHandler,
1801
- version: addVersionEventHandler,
1802
- logLevel: addLogLevelEventHandler,
1803
- requiresHardRefresh: addRequiresHardRefreshEventHandler,
1804
- warnOutdatedApp: addWarnOutdatedAppEventHandler,
1805
- studioMode: addStudioModeEventHandler,
1806
- basePath: addBasePathEventHandler,
1807
- versionCheckInterval: addVersionCheckIntervalEventHandler,
1808
- cliVersion: addCliVersionEventHandler,
1809
- fileUploadOperationsChunkSize: addFileUploadOperationsChunkSizeEventHandler,
1810
- isDocumentModelSelectionSettingsEnabled: addIsDocumentModelSelectionSettingsEnabledEventHandler,
1811
- gaTrackingId: addGaTrackingIdEventHandler,
1812
- allowList: addAllowListEventHandler,
1813
- defaultDrivesUrl: addDefaultDrivesUrlEventHandler,
1814
- drivesPreserveStrategy: addDrivesPreserveStrategyEventHandler,
1815
- allowedDocumentTypes: addAllowedDocumentTypesEventHandler,
1816
- enabledEditors: addEnabledEditorsEventHandler,
1817
- disabledEditors: addDisabledEditorsEventHandler,
1818
- isAddDriveEnabled: addIsAddDriveEnabledEventHandler,
1819
- isLocalDrivesEnabled: addIsLocalDrivesEnabledEventHandler,
1820
- isPublicDrivesEnabled: addIsPublicDrivesEnabledEventHandler,
1821
- isAddPublicDrivesEnabled: addIsAddPublicDrivesEnabledEventHandler,
1822
- isDeletePublicDrivesEnabled: addIsDeletePublicDrivesEnabledEventHandler,
1823
- isCloudDrivesEnabled: addIsCloudDrivesEnabledEventHandler,
1824
- isAddCloudDrivesEnabled: addIsAddCloudDrivesEnabledEventHandler,
1825
- isDeleteCloudDrivesEnabled: addIsDeleteCloudDrivesEnabledEventHandler,
1826
- isAddLocalDrivesEnabled: addIsAddLocalDrivesEnabledEventHandler,
1827
- isDeleteLocalDrivesEnabled: addIsDeleteLocalDrivesEnabledEventHandler,
1828
- isDragAndDropEnabled: addIsDragAndDropEnabledEventHandler,
1829
- isExternalControlsEnabled: addIsExternalControlsEnabledEventHandler,
1830
- isEditorDebugModeEnabled: addIsEditorDebugModeEnabledEventHandler,
1831
- isEditorReadModeEnabled: addIsEditorReadModeEnabledEventHandler,
1832
- isRelationalProcessorsEnabled: addIsRelationalProcessorsEnabledEventHandler,
1833
- isExternalRelationalProcessorsEnabled: addIsExternalRelationalProcessorsEnabledEventHandler,
1834
- isAnalyticsEnabled: addIsAnalyticsEnabledEventHandler,
1835
- isAnalyticsExternalProcessorsEnabled: addIsAnalyticsExternalProcessorsEnabledEventHandler,
1836
- analyticsDatabaseName: addAnalyticsDatabaseNameEventHandler,
1837
- isAnalyticsDatabaseWorkerEnabled: addIsAnalyticsDatabaseWorkerEnabledEventHandler,
1838
- isDiffAnalyticsEnabled: addIsDiffAnalyticsEnabledEventHandler,
1839
- isDriveAnalyticsEnabled: addIsDriveAnalyticsEnabledEventHandler,
1840
- renownUrl: addRenownUrlEventHandler,
1841
- renownNetworkId: addRenownNetworkIdEventHandler,
1842
- renownChainId: addRenownChainIdEventHandler,
1843
- sentryRelease: addSentryReleaseEventHandler,
1844
- sentryDsn: addSentryDsnEventHandler,
1845
- sentryEnv: addSentryEnvEventHandler,
1846
- isSentryTracingEnabled: addIsSentryTracingEnabledEventHandler,
1847
- isExternalProcessorsEnabled: addIsExternalProcessorsEnabledEventHandler,
1848
- isExternalPackagesEnabled: addIsExternalPackagesEnabledEventHandler,
1849
- toast: addToastEventHandler
1850
- };
1851
- function addPHEventHandlers() {
1852
- callEventHandlerRegisterFunctions(phGlobalEventHandlerRegisterFunctions);
1853
- }
1854
- function callEventHandlerRegisterFunctions(registerFunctions) {
1855
- forEachObj(registerFunctions, (fn) => fn());
1856
- }
1857
- //#endregion
1858
- //#region src/hooks/document-model-modules.ts
1859
- function useDocumentModelModules() {
1860
- return useVetraPackages().flatMap((pkg) => pkg.documentModels).filter((module, index, modules) => modules.findIndex((m) => m.documentModel.global.id === module.documentModel.global.id && m.version === module.version) === index);
1861
- }
1862
- function useDocumentModelModuleById(id) {
1863
- return useDocumentModelModules()?.find((module) => module.documentModel.global.id === id);
1864
- }
1865
- //#endregion
1866
438
  //#region src/hooks/allowed-document-model-modules.ts
1867
439
  function useAllowedDocumentModelModules() {
1868
440
  const documentModelModules = useDocumentModelModules();
@@ -2059,90 +631,6 @@ function useDocumentOfType(documentId, documentType) {
2059
631
  return [document, dispatch];
2060
632
  }
2061
633
  //#endregion
2062
- //#region src/hooks/document-operations.ts
2063
- /**
2064
- * Hook to fetch document operations via the reactor client.
2065
- * Operations are no longer auto-populated on documents and must be fetched explicitly.
2066
- *
2067
- * @param documentId - The document ID to fetch operations for
2068
- * @returns Object containing globalOperations, localOperations, isLoading, and error
2069
- */
2070
- function useDocumentOperations(documentId) {
2071
- const reactorClient = useReactorClient();
2072
- const hasFetchedRef = useRef(false);
2073
- const [state, setState] = useState(() => ({
2074
- globalOperations: [],
2075
- localOperations: [],
2076
- isLoading: !!documentId,
2077
- error: void 0
2078
- }));
2079
- const fetchOperations = useCallback(async (retryCount = 0) => {
2080
- const MAX_RETRIES = 5;
2081
- const RETRY_DELAY_MS = 500;
2082
- if (!documentId || !reactorClient) {
2083
- setState({
2084
- globalOperations: [],
2085
- localOperations: [],
2086
- isLoading: false,
2087
- error: void 0
2088
- });
2089
- return;
2090
- }
2091
- setState((prev) => ({
2092
- ...prev,
2093
- isLoading: true,
2094
- error: void 0
2095
- }));
2096
- let globalOps = [];
2097
- let localOps = [];
2098
- let fetchError;
2099
- try {
2100
- globalOps = (await reactorClient.getOperations(documentId, { scopes: ["global"] })).results;
2101
- } catch (err) {
2102
- fetchError = err instanceof Error ? err : new Error(String(err));
2103
- }
2104
- if (!fetchError) try {
2105
- localOps = (await reactorClient.getOperations(documentId, { scopes: ["local"] })).results;
2106
- } catch (err) {
2107
- fetchError = err instanceof Error ? err : new Error(String(err));
2108
- }
2109
- if (!fetchError && globalOps.length === 0 && localOps.length === 0 && retryCount < MAX_RETRIES) {
2110
- await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS));
2111
- return fetchOperations(retryCount + 1);
2112
- }
2113
- setState({
2114
- globalOperations: globalOps,
2115
- localOperations: localOps,
2116
- isLoading: false,
2117
- error: fetchError
2118
- });
2119
- hasFetchedRef.current = true;
2120
- }, [documentId, reactorClient]);
2121
- useEffect(() => {
2122
- if (documentId && reactorClient) fetchOperations();
2123
- else if (!documentId) {
2124
- setState({
2125
- globalOperations: [],
2126
- localOperations: [],
2127
- isLoading: false,
2128
- error: void 0
2129
- });
2130
- hasFetchedRef.current = false;
2131
- }
2132
- }, [
2133
- documentId,
2134
- reactorClient,
2135
- fetchOperations
2136
- ]);
2137
- const refetch = useCallback(() => {
2138
- fetchOperations(0);
2139
- }, [fetchOperations]);
2140
- return {
2141
- ...state,
2142
- refetch
2143
- };
2144
- }
2145
- //#endregion
2146
634
  //#region src/hooks/supported-document-types.ts
2147
635
  /** Returns the supported document types for the reactor (derived from the document model modules) */
2148
636
  function useSupportedDocumentTypesInReactor() {
@@ -2161,6 +649,52 @@ function useDocumentTypes() {
2161
649
  return allowedDocumentTypes ?? supportedDocumentTypes;
2162
650
  }
2163
651
  //#endregion
652
+ //#region src/hooks/document-version-status.ts
653
+ /**
654
+ * Classifies a document's model version against the installed module
655
+ * versions. Pure logic, extracted for testing.
656
+ */
657
+ function getDocumentVersionStatus(documentVersion, availableVersions, hasUpgradePath) {
658
+ if (availableVersions.length === 0) return;
659
+ const sorted = [...availableVersions].sort((a, b) => a - b);
660
+ const latestVersion = sorted[sorted.length - 1];
661
+ if (documentVersion > latestVersion) return {
662
+ kind: "unsupported",
663
+ documentVersion,
664
+ availableVersions: sorted
665
+ };
666
+ if (documentVersion === latestVersion) return {
667
+ kind: "current",
668
+ documentVersion
669
+ };
670
+ return {
671
+ kind: "upgrade-available",
672
+ documentVersion,
673
+ latestVersion,
674
+ canUpgrade: hasUpgradePath(documentVersion, latestVersion)
675
+ };
676
+ }
677
+ /**
678
+ * Compares the given document's model version against the versions available
679
+ * from installed Vetra packages. Returns undefined while packages load or
680
+ * when the document type has no installed modules.
681
+ */
682
+ function useDocumentVersionStatus(document) {
683
+ const modules = useDocumentModelModules();
684
+ const registry = useModelRegistry();
685
+ if (!document || !modules) return;
686
+ const documentType = document.header.documentType;
687
+ return getDocumentVersionStatus(document.state.document.version || 1, modules.filter((m) => m.documentModel.global.id === documentType).map((m) => m.version ?? 1), (fromVersion, toVersion) => {
688
+ if (!registry) return false;
689
+ try {
690
+ registry.computeUpgradePath(documentType, fromVersion, toVersion);
691
+ return true;
692
+ } catch {
693
+ return false;
694
+ }
695
+ });
696
+ }
697
+ //#endregion
2164
698
  //#region src/utils/validate-document.ts
2165
699
  const validateDocument = (document) => {
2166
700
  const errors = [];
@@ -2909,6 +1443,116 @@ function buildDocumentSubgraphUrl(driveUrl, identifier, authToken) {
2909
1443
  return `${driveUrl}?explorerURLState=${buildDocumentSubgraphQuery(identifier, authToken)}`;
2910
1444
  }
2911
1445
  //#endregion
1446
+ //#region src/utils/upgrade-preview.ts
1447
+ const NON_DOMAIN_SCOPES = new Set(["auth", "document"]);
1448
+ function isPlainObject(value) {
1449
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1450
+ }
1451
+ function walkShapes(before, after, path, added, removed) {
1452
+ if (isPlainObject(before) && isPlainObject(after)) {
1453
+ const beforeKeys = Object.keys(before);
1454
+ const afterKeys = Object.keys(after);
1455
+ for (const key of afterKeys) {
1456
+ const childPath = path ? `${path}.${key}` : key;
1457
+ if (!beforeKeys.includes(key)) {
1458
+ added.push(childPath);
1459
+ continue;
1460
+ }
1461
+ walkShapes(before[key], after[key], childPath, added, removed);
1462
+ }
1463
+ for (const key of beforeKeys) if (!afterKeys.includes(key)) removed.push(path ? `${path}.${key}` : key);
1464
+ return;
1465
+ }
1466
+ if (Array.isArray(before) && Array.isArray(after)) {
1467
+ if (before.length > 0 && after.length > 0) walkShapes(before[0], after[0], `${path}[]`, added, removed);
1468
+ }
1469
+ }
1470
+ /**
1471
+ * Recursively diffs the structural shape of two values, returning dot-paths
1472
+ * of keys present in `after` but not `before` (added) and vice versa
1473
+ * (removed). Array fields are compared by the shape of a representative
1474
+ * element (the first element on each side, when both sides have one) using
1475
+ * the `path[]` notation, e.g. `todos[].status`. Only key presence is
1476
+ * compared — array length and primitive values are ignored.
1477
+ */
1478
+ function diffStateShapes(before, after) {
1479
+ const added = [];
1480
+ const removed = [];
1481
+ walkShapes(before, after, "", added, removed);
1482
+ return {
1483
+ added,
1484
+ removed
1485
+ };
1486
+ }
1487
+ /**
1488
+ * Computes a dry-run preview of upgrading `document` to the latest
1489
+ * registered version of its document model: the version jump, the upgrade
1490
+ * steps that will run, and which state fields will be added or removed.
1491
+ * Applies the upgrade reducers against a deep clone of the document, so the
1492
+ * original is left untouched.
1493
+ *
1494
+ * Returns undefined when the registry is unavailable, the document is
1495
+ * already at (or above) the latest registered version, or the upgrade path
1496
+ * cannot be computed.
1497
+ */
1498
+ function getDocumentUpgradePreview(document, registry) {
1499
+ if (!registry) return;
1500
+ const documentType = document.header.documentType;
1501
+ const fromVersion = document.state.document.version || 1;
1502
+ let latestVersion;
1503
+ try {
1504
+ latestVersion = registry.getLatestVersion(documentType);
1505
+ } catch {
1506
+ return;
1507
+ }
1508
+ if (fromVersion >= latestVersion) return;
1509
+ let transitions;
1510
+ try {
1511
+ transitions = registry.computeUpgradePath(documentType, fromVersion, latestVersion);
1512
+ } catch {
1513
+ return;
1514
+ }
1515
+ const stubAction = {
1516
+ id: "",
1517
+ type: "UPGRADE_DOCUMENT",
1518
+ scope: "document",
1519
+ timestampUtcMs: "",
1520
+ input: {
1521
+ documentId: document.header.id,
1522
+ model: documentType,
1523
+ fromVersion,
1524
+ toVersion: latestVersion
1525
+ }
1526
+ };
1527
+ let upgraded = structuredClone(document);
1528
+ try {
1529
+ for (const transition of transitions) upgraded = transition.upgradeReducer(upgraded, stubAction);
1530
+ } catch {
1531
+ return;
1532
+ }
1533
+ const addedFields = [];
1534
+ const removedFields = [];
1535
+ const scopes = new Set([...Object.keys(document.state), ...Object.keys(upgraded.state)]);
1536
+ for (const scope of scopes) {
1537
+ if (NON_DOMAIN_SCOPES.has(scope)) continue;
1538
+ const beforeScope = document.state[scope];
1539
+ const afterScope = upgraded.state[scope];
1540
+ const { added, removed } = diffStateShapes(beforeScope, afterScope);
1541
+ for (const path of added) addedFields.push(`${scope}.${path}`);
1542
+ for (const path of removed) removedFields.push(`${scope}.${path}`);
1543
+ }
1544
+ return {
1545
+ fromVersion,
1546
+ toVersion: latestVersion,
1547
+ steps: transitions.map((transition) => ({
1548
+ toVersion: transition.toVersion,
1549
+ description: transition.description ?? ""
1550
+ })),
1551
+ addedFields,
1552
+ removedFields
1553
+ };
1554
+ }
1555
+ //#endregion
2912
1556
  //#region src/hooks/use-get-switchboard-link.ts
2913
1557
  /**
2914
1558
  * Hook that returns a function to generate a document's switchboard URL.
@@ -2996,6 +1640,90 @@ function useAttachments() {
2996
1640
  const service = useAttachmentService();
2997
1641
  return useMemo(() => service ? createAttachmentClient(service) : void 0, [service]);
2998
1642
  }
1643
+ const DEFAULT_PREVIEW_RETRIES = 3;
1644
+ const DEFAULT_PREVIEW_RETRY_DELAY_MS = 3e3;
1645
+ /**
1646
+ * Document-authorized inline preview of an attachment. Downloads the bytes
1647
+ * through the normal authorized flow, exposes them as an object URL, and
1648
+ * revokes it automatically on unmount and whenever documentId/ref change —
1649
+ * editors never touch blobs or URL lifecycles. Failed attempts are retried
1650
+ * (`retries` × `retryDelayMs`) so a preview requested right after attaching
1651
+ * appears as soon as the server's reference index catches up.
1652
+ */
1653
+ function useAttachmentPreview({ documentId, ref, retries = DEFAULT_PREVIEW_RETRIES, retryDelayMs = DEFAULT_PREVIEW_RETRY_DELAY_MS }) {
1654
+ const client = useAttachments();
1655
+ const [state, setState] = useState({
1656
+ url: void 0,
1657
+ header: void 0,
1658
+ loading: false,
1659
+ error: void 0
1660
+ });
1661
+ useEffect(() => {
1662
+ if (!client || !ref) {
1663
+ setState({
1664
+ url: void 0,
1665
+ header: void 0,
1666
+ loading: false,
1667
+ error: void 0
1668
+ });
1669
+ return;
1670
+ }
1671
+ let cancelled = false;
1672
+ let revoke;
1673
+ let timer;
1674
+ let attempt = 0;
1675
+ setState({
1676
+ url: void 0,
1677
+ header: void 0,
1678
+ loading: true,
1679
+ error: void 0
1680
+ });
1681
+ const load = () => {
1682
+ client.downloadObjectUrl({
1683
+ documentId,
1684
+ ref
1685
+ }).then((result) => {
1686
+ if (cancelled) {
1687
+ result.revoke();
1688
+ return;
1689
+ }
1690
+ revoke = result.revoke;
1691
+ setState({
1692
+ url: result.url,
1693
+ header: result.header,
1694
+ loading: false,
1695
+ error: void 0
1696
+ });
1697
+ }).catch((err) => {
1698
+ if (cancelled) return;
1699
+ if (attempt < retries) {
1700
+ attempt += 1;
1701
+ timer = setTimeout(load, retryDelayMs);
1702
+ return;
1703
+ }
1704
+ setState({
1705
+ url: void 0,
1706
+ header: void 0,
1707
+ loading: false,
1708
+ error: err instanceof Error ? err : new Error(String(err))
1709
+ });
1710
+ });
1711
+ };
1712
+ load();
1713
+ return () => {
1714
+ cancelled = true;
1715
+ if (timer !== void 0) clearTimeout(timer);
1716
+ revoke?.();
1717
+ };
1718
+ }, [
1719
+ client,
1720
+ documentId,
1721
+ ref,
1722
+ retries,
1723
+ retryDelayMs
1724
+ ]);
1725
+ return state;
1726
+ }
2999
1727
  /** Upload lifecycle status. progress is coarse (0 before/during, 1 on Done) because RemoteAttachmentUpload buffers the full body before issuing a single PUT. */
3000
1728
  let UploadStatus = /* @__PURE__ */ function(UploadStatus) {
3001
1729
  UploadStatus["None"] = "None";
@@ -3371,105 +2099,6 @@ var RemoteClient = class {
3371
2099
  }
3372
2100
  };
3373
2101
  //#endregion
3374
- //#region src/remote-controller/utils.ts
3375
- /** Convert SCREAMING_SNAKE_CASE to camelCase (e.g. "SET_MODEL_NAME" → "setModelName"). */
3376
- function screamingSnakeToCamel(s) {
3377
- return s.toLowerCase().replace(/_([a-z])/g, (_, c) => c.toUpperCase());
3378
- }
3379
- /** Error thrown when a push conflict is detected with the "reject" strategy. */
3380
- var ConflictError = class extends Error {
3381
- constructor(conflict) {
3382
- super("Push conflict: remote has new operations since last pull");
3383
- this.conflict = conflict;
3384
- this.name = "ConflictError";
3385
- }
3386
- };
3387
- /** Convert a remote operation to the local Operation type. */
3388
- function remoteOperationToLocal(remote) {
3389
- return {
3390
- id: remote.id ?? "",
3391
- index: remote.index,
3392
- skip: remote.skip,
3393
- timestampUtcMs: remote.timestampUtcMs,
3394
- hash: remote.hash,
3395
- error: remote.error ?? void 0,
3396
- action: {
3397
- id: remote.action.id,
3398
- type: remote.action.type,
3399
- timestampUtcMs: remote.action.timestampUtcMs,
3400
- input: remote.action.input,
3401
- scope: remote.action.scope,
3402
- context: remote.action.context?.signer ? { signer: {
3403
- user: remote.action.context.signer.user ?? {
3404
- address: "",
3405
- networkId: "",
3406
- chainId: 0
3407
- },
3408
- app: remote.action.context.signer.app ?? {
3409
- name: "",
3410
- key: ""
3411
- },
3412
- signatures: remote.action.context.signer.signatures.map((s) => deserializeSignature(s))
3413
- } } : void 0
3414
- }
3415
- };
3416
- }
3417
- /**
3418
- * Deserialize a signature string back to a 5-element tuple.
3419
- * The server serializes tuples via `tuple.join(", ")`.
3420
- */
3421
- function deserializeSignature(s) {
3422
- const parts = s.split(", ");
3423
- return [
3424
- parts[0] ?? "",
3425
- parts[1] ?? "",
3426
- parts[2] ?? "",
3427
- parts[3] ?? "",
3428
- parts[4] ?? ""
3429
- ];
3430
- }
3431
- /** Convert remote operations to local DocumentOperations format. */
3432
- function convertRemoteOperations(operationsByScope) {
3433
- const operations = {};
3434
- for (const [scope, remoteOps] of Object.entries(operationsByScope)) operations[scope] = remoteOps.map((op) => remoteOperationToLocal(op));
3435
- return operations;
3436
- }
3437
- /** Reconstruct a PHDocument from remote document data and operations. */
3438
- function buildPulledDocument(remoteDoc, operations, initialDoc, branch) {
3439
- return {
3440
- header: {
3441
- ...initialDoc.header,
3442
- id: remoteDoc.id,
3443
- name: remoteDoc.name,
3444
- slug: remoteDoc.slug ?? "",
3445
- documentType: remoteDoc.documentType,
3446
- createdAtUtcIso: typeof remoteDoc.createdAtUtcIso === "string" ? remoteDoc.createdAtUtcIso : remoteDoc.createdAtUtcIso.toISOString(),
3447
- lastModifiedAtUtcIso: typeof remoteDoc.lastModifiedAtUtcIso === "string" ? remoteDoc.lastModifiedAtUtcIso : remoteDoc.lastModifiedAtUtcIso.toISOString(),
3448
- revision: Object.fromEntries(remoteDoc.revisionsList.map((r) => [r.scope, r.revision])),
3449
- branch
3450
- },
3451
- state: remoteDoc.state,
3452
- initialState: initialDoc.initialState,
3453
- operations,
3454
- clipboard: []
3455
- };
3456
- }
3457
- /** Extract revision map from a remote document's revisionsList. */
3458
- function extractRevisionMap(revisionsList) {
3459
- return Object.fromEntries(revisionsList.map((r) => [r.scope, r.revision]));
3460
- }
3461
- /**
3462
- * Check if any scope in currentRevision is ahead of knownRevision.
3463
- * When `scopes` is provided, only those scopes are checked.
3464
- */
3465
- function hasRevisionConflict(currentRevision, knownRevision, scopes) {
3466
- for (const scope in currentRevision) {
3467
- if (scopes && !scopes.has(scope)) continue;
3468
- if ((currentRevision[scope] ?? 0) > (knownRevision[scope] ?? 0)) return true;
3469
- }
3470
- return false;
3471
- }
3472
- //#endregion
3473
2102
  //#region src/remote-controller/remote-controller.ts
3474
2103
  /**
3475
2104
  * A controller that wraps a PHDocumentController with remote push/pull capabilities.
@@ -3860,6 +2489,6 @@ var BrowserLocalStorage = class extends BaseStorage {
3860
2489
  }
3861
2490
  };
3862
2491
  //#endregion
3863
- export { ActionTracker, BaseStorage, BrowserLocalStorage, COMMON_PACKAGE_ID, CREDENTIAL_SCHEMA_EIP712_TYPE, CREDENTIAL_SUBJECT_TYPE, CREDENTIAL_TYPES, ChannelScheme, ChevronDownIcon, ConflictError, CopyIcon, DEFAULT_DRIVE_EDITOR_ID, DEFAULT_DRIVE_ID, DEFAULT_SWITCHBOARD_URL, DOMAIN_TYPE, DRIVE_DOCUMENT_TYPES, DisconnectIcon, DocumentCache, DocumentChangeType, DocumentIntegrityService, DriveCollectionId, EDITOR_FILE_DROP_OPT_OUT_ATTR, GqlRequestChannel, GraphQLClientDocumentCache, ISSUER_TYPE, InMemoryQueue, IntervalPollTimer, PollBehavior, PropagationMode, REACTOR_SCHEMA, RENOWN_CHAIN_ID, RENOWN_NETWORK_ID, RENOWN_URL, ReactorBuilder, ReactorClientBuilder, RegistryClient, RelationalDbProcessor, RemoteClient, RemoteDocumentController, Renown, RenownAuthButton, RenownLoginButton, RenownLogo, RenownUserButton, SpinnerIcon, SyncOperationStatus, UploadStatus, UserIcon, VERIFIABLE_CREDENTIAL_EIP712_TYPE, addAllowListEventHandler, addAllowedDocumentTypesEventHandler, addAnalyticsDatabaseNameEventHandler, addAttachmentServiceEventHandler, addBasePathEventHandler, addCliVersionEventHandler, addDefaultDrivesUrlEventHandler, addDisabledEditorsEventHandler, addDocument, addDocumentCacheEventHandler, addDraggingNodeEventHandler, addDrive, addDrivesEventHandler, addDrivesPreserveStrategyEventHandler, addEnabledEditorsEventHandler, addFeaturesEventHandler, addFileUploadOperationsChunkSizeEventHandler, addFolder, addGaTrackingIdEventHandler, addGraphQLReactorClientEventHandler, addIsAddCloudDrivesEnabledEventHandler, addIsAddDriveEnabledEventHandler, addIsAddLocalDrivesEnabledEventHandler, addIsAddPublicDrivesEnabledEventHandler, addIsAnalyticsDatabaseWorkerEnabledEventHandler, addIsAnalyticsEnabledEventHandler, addIsAnalyticsExternalProcessorsEnabledEventHandler, addIsCloudDrivesEnabledEventHandler, addIsDeleteCloudDrivesEnabledEventHandler, addIsDeleteLocalDrivesEnabledEventHandler, addIsDeletePublicDrivesEnabledEventHandler, addIsDiffAnalyticsEnabledEventHandler, addIsDocumentModelSelectionSettingsEnabledEventHandler, addIsDragAndDropEnabledEventHandler, addIsDriveAnalyticsEnabledEventHandler, addIsEditorDebugModeEnabledEventHandler, addIsEditorReadModeEnabledEventHandler, addIsExternalControlsEnabledEventHandler, addIsExternalPackagesEnabledEventHandler, addIsExternalProcessorsEnabledEventHandler, addIsExternalRelationalProcessorsEnabledEventHandler, addIsLocalDrivesEnabledEventHandler, addIsPublicDrivesEnabledEventHandler, addIsRelationalProcessorsEnabledEventHandler, addIsSentryTracingEnabledEventHandler, addLoadingEventHandler, addLocalDrivesEnabledEventHandler, addLogLevelEventHandler, addModalEventHandler, addPHEventHandlers, addPackageDiscoveryServiceEventHandler, addPromiseState, addReactorClientEventHandler, addReactorClientModuleEventHandler, addRemoteDrive, addRenownChainIdEventHandler, addRenownEventHandler, addRenownNetworkIdEventHandler, addRenownUrlEventHandler, addRequiresHardRefreshEventHandler, addResetSelectedNodeEventHandler, addRevisionHistoryVisibleEventHandler, addRouterBasenameEventHandler, addSelectedDriveIdEventHandler, addSelectedNodeIdEventHandler, addSelectedTimelineItemEventHandler, addSelectedTimelineRevisionEventHandler, addSentryDsnEventHandler, addSentryEnvEventHandler, addSentryReleaseEventHandler, addSetSelectedDriveOnPopStateEventHandler, addSetSelectedNodeOnPopStateEventHandler, addStudioModeEventHandler, addToastEventHandler, addVersionCheckIntervalEventHandler, addVersionEventHandler, addVetraPackageManagerEventHandler, addWarnOutdatedAppEventHandler, baseDocumentModels, baseDocumentModelsMap, buildDocumentSubgraphQuery, buildDocumentSubgraphUrl, callEventHandlerRegisterFunctions, callGlobalSetterForKey, clearGlobal, closePHModal, commonGlobalEventHandlerFunctions, convertRemoteOperations, createAnalyticsStore, createClient, createProcessorQuery, createUrlWithPreservedParams, deleteDrive, deleteNode, deriveSystemUrl, dispatchActions, downloadDocument, driveIdFromUrl, dropAllReactorStorage, exportFile, extractDriveIdFromPath, extractDriveIdFromSlug, extractDriveSlugFromPath, extractNodeIdFromPath, extractNodeIdFromSlug, extractNodeSlugFromPath, findUuid, getAnalyticsStore, getDocumentGraphqlQuery, getDriveIdBySlug, getDrives, getGlobal, getPackages, getPackagesByDocumentType, getPathWithoutBase, getRevisionFromDate, getSlugFromDriveUrl, getSwitchboardGatewayUrlFromDriveUrl, getSyncStatus, getSyncStatusSync, getUserPermissions, graphqlDocumentEvents, graphqlDocumentsEvents, graphqlEventsToSyncDrive, hasPreloadBandwidth, hideRevisionHistory, identifierFromMutateDocumentOperationVariables, initConnectCrypto, initRenownCrypto, initTheme, isDocumentTypeSupported, isDriveAuthError, isExternalControlsEnabledEventFunctions, isFileNodeKind, isFolderNodeKind, loading, login, logout, makeDriveUrlComponent, makeNodeSlug, makePHEventFunctions, openRenown, parseDriveUrl, phAppConfigHooks, phAppConfigSetters, phDocumentEditorConfigHooks, phDocumentEditorConfigSetters, phDocumentFromQuery, phDocumentsFromQuery, phGlobalConfigHooks, phGlobalConfigSetters, preloadEditorModule, reactorGraphqlBatchFetchDocuments, reactorGraphqlCreateDocument, reactorGraphqlDeleteDocument, reactorGraphqlDeleteDocuments, reactorGraphqlFetchDocument, reactorGraphqlMutateDocument, readPromiseState, refreshReactorData, refreshReactorDataClient, renameDrive, renameDriveNode, resolveUrlPathname, setAllowList, setAllowedDocumentTypes, setAnalyticsDatabaseName, setAttachmentService, setBasePath, setCliVersion, setDefaultDrivesUrl, setDefaultPHGlobalConfig, setDisabledEditors, setDocumentCache, setDriveAvailableOffline, setDriveMetadata, setDriveSharingType, setDrives, setDrivesPreserveStrategy, setEnabledEditors, setFeatures, setFileUploadOperationsChunkSize, setGaTrackingId, setGlobal, setGraphQLReactorClient, setIsAddCloudDrivesEnabled, setIsAddDriveEnabled, setIsAddLocalDrivesEnabled, setIsAddPublicDrivesEnabled, setIsAnalyticsDatabaseWorkerEnabled, setIsAnalyticsEnabled, setIsAnalyticsExternalProcessorsEnabled, setIsCloudDrivesEnabled, setIsDeleteCloudDrivesEnabled, setIsDeleteLocalDrivesEnabled, setIsDeletePublicDrivesEnabled, setIsDiffAnalyticsEnabled, setIsDocumentModelSelectionSettingsEnabled, setIsDragAndDropEnabled, setIsDriveAnalyticsEnabled, setIsEditorDebugModeEnabled, setIsEditorReadModeEnabled, setIsExternalControlsEnabled, setIsExternalPackagesEnabled, setIsExternalProcessorsEnabled, setIsExternalRelationalProcessorsEnabled, setIsLocalDrivesEnabled, setIsPublicDrivesEnabled, setIsRelationalProcessorsEnabled, setIsSentryTracingEnabled, setLoading, setLocalDrivesEnabled, setLogLevel, setPGliteDB, setPHAppConfig, setPHAppConfigByKey, setPHDocumentEditorConfig, setPHDocumentEditorConfigByKey, setPHGlobalConfig, setPHGlobalConfigByKey, setPHModal, setPHToast, setPackageDiscoveryService, setReactorClient, setReactorClientModule, setRenown, setRenownChainId, setRenownNetworkId, setRenownUrl, setRequiresHardRefresh, setRevisionHistoryVisible, setRouterBasename, setSelectedDrive, setSelectedDriveId, setSelectedNode, setSelectedTimelineItem, setSelectedTimelineRevision, setSentryDsn, setSentryEnv, setSentryRelease, setStudioMode, setVersion, setVersionCheckInterval, setVetraPackageManager, setWarnOutdatedApp, showCreateDocumentModal, showDeleteNodeModal, showPHModal, showRevisionHistory, sortNodesByName, trimTrailingSlash, truncateAllTables, useAllowList, useAllowedDocumentModelModules, useAllowedDocumentTypes, useAnalyticsDatabaseName, useAppModuleById, useAppModules, useAttachmentService, useAttachmentUpload, useAttachments, useBasePath, useCliVersion, useConnectionState, useConnectionStates, useDatabase, useDefaultAppModule, useDefaultDrivesUrl, useDid, useDisabledEditors, useDispatch, useDocument, useDocumentById, useDocumentCache, useDocumentModelModuleById, useDocumentModelModules, useDocumentOfType, useDocumentOperations, useDocumentSafe, useDocumentTypes, useDocumentTypesInSelectedDrive, useDocuments, useDocumentsByIds, useDocumentsInSelectedDrive, useDocumentsInSelectedFolder, useDownloadDocument, useDragNode, useDriveById, useDriveSystemInfo, useDrives, useDrivesPreserveStrategy, useDropFile, useDropNode, useEditorFileDrop, useEditorModuleById, useEditorModules, useEditorModulesForDocumentType, useEditorPreloader, useEnabledEditors, useFallbackEditorModule, useFeatures, useFileNodesInSelectedDrive, useFileNodesInSelectedFolder, useFileUploadOperationsChunkSize, useFolderById, useFolderNodesInSelectedDrive, useFolderNodesInSelectedFolder, useGaTrackingId, useGetDocument, useGetDocumentAsync, useGetDocuments, useGetSwitchboardLink, useGraphQLReactorClient, useInitReactorGraphqlClient, useIsAddCloudDrivesEnabled, useIsAddDriveEnabled, useIsAddLocalDrivesEnabled, useIsAddPublicDrivesEnabled, useIsAnalyticsDatabaseWorkerEnabled, useIsAnalyticsEnabled, useIsAnalyticsExternalProcessorsEnabled, useIsCloudDrivesEnabled, useIsDeleteCloudDrivesEnabled, useIsDeleteLocalDrivesEnabled, useIsDeletePublicDrivesEnabled, useIsDiffAnalyticsEnabled, useIsDocumentModelSelectionSettingsEnabled, useIsDragAndDropEnabled, useIsDriveAnalyticsEnabled, useIsEditorDebugModeEnabled, useIsEditorReadModeEnabled, useIsExternalControlsEnabled, useIsExternalPackagesEnabled, useIsExternalProcessorsEnabled, useIsExternalRelationalProcessorsEnabled, useIsLocalDrivesEnabled, useIsPublicDrivesEnabled, useIsRelationalProcessorsEnabled, useIsSentryTracingEnabled, useLoading, useLocalDrivesEnabled, useLogLevel, useLoginStatus, useModelRegistry, useNodeActions, useNodeById, useNodeParentFolderById, useNodePathById, useNodesInSelectedDrive, useNodesInSelectedDriveOrFolder, useNodesInSelectedFolder, useOnDropFile, usePGlite, usePHAppConfigByKey, usePHDocumentEditorConfigByKey, usePHGlobalConfigByKey, usePHModal, usePHToast, usePackageDiscoveryService, useParentFolderForSelectedNode, useReactorClient, useReactorClientModule, useRelationalDb, useRelationalQuery, useRenown, useRenownAuth, useRenownChainId, useRenownInit, useRenownNetworkId, useRenownUrl, useRequiresHardRefresh, useResetPHGlobalConfig, useRevisionHistoryVisible, useRouterBasename, useSelectedDocument, useSelectedDocumentId, useSelectedDocumentOfType, useSelectedDocumentSafe, useSelectedDrive, useSelectedDriveId, useSelectedDriveSafe, useSelectedFolder, useSelectedNode, useSelectedNodePath, useSelectedTimelineItem, useSelectedTimelineRevision, useSentryDsn, useSentryEnv, useSentryRelease, useSetDefaultPHGlobalConfig, useSetPHAppConfig, useSetPHDocumentEditorConfig, useSetPHGlobalConfig, useStudioMode, useSubgraphModules, useSupportedDocumentTypesInReactor, useSync, useSyncList, useTheme, useUser, useUserPermissions, useVersion, useVersionCheckInterval, useVetraPackageManager, useVetraPackages, useWarnOutdatedApp, validateDocument, waitForDocumentReady };
2492
+ export { ActionTracker, BaseStorage, BrowserLocalStorage, COMMON_PACKAGE_ID, CREDENTIAL_SCHEMA_EIP712_TYPE, CREDENTIAL_SUBJECT_TYPE, CREDENTIAL_TYPES, ChannelScheme, ChevronDownIcon, ConflictError, CopyIcon, DEFAULT_DRIVE_EDITOR_ID, DEFAULT_DRIVE_ID, DEFAULT_SWITCHBOARD_URL, DOMAIN_TYPE, DRIVE_DOCUMENT_TYPES, DisconnectIcon, DocumentCache, DocumentChangeType, DocumentIntegrityService, DocumentModelNotFoundError, DocumentNotFoundError, DocumentTypeMismatchError, DriveCollectionId, EDITOR_FILE_DROP_OPT_OUT_ATTR, GqlRequestChannel, GraphQLClientDocumentCache, GraphQLReactorClient, GraphQLReactorProvider, ISSUER_TYPE, InMemoryQueue, IntervalPollTimer, MutateDocumentWithOperationsDocument, NoSelectedDocumentError, PollBehavior, PropagationMode, REACTOR_SCHEMA, RENOWN_CHAIN_ID, RENOWN_INITIAL_ANONYMOUS, RENOWN_INITIAL_UNKNOWN, RENOWN_NETWORK_ID, RENOWN_URL, ReactorBuilder, ReactorClientBuilder, ReactorOperationFieldsFragmentDoc, RegistryClient, RelationalDbProcessor, RemoteClient, RemoteDocumentController, Renown, RenownAuthButton, RenownInitialUserProvider, RenownLoginButton, RenownLogo, RenownProvider, RenownUserButton, RenownWalletProvider, SpinnerIcon, StaticPackageManager, SubgraphSdkRegistry, SyncOperationStatus, UnsupportedDocumentTypeError, UploadStatus, UserIcon, VERIFIABLE_CREDENTIAL_EIP712_TYPE, addAllowListEventHandler, addAllowedDocumentTypesEventHandler, addAnalyticsDatabaseNameEventHandler, addAttachmentServiceEventHandler, addBasePathEventHandler, addCliVersionEventHandler, addDefaultDrivesUrlEventHandler, addDisabledEditorsEventHandler, addDocument, addDocumentCacheEventHandler, addDraggingNodeEventHandler, addDrive, addDrivesEventHandler, addDrivesPreserveStrategyEventHandler, addEnabledEditorsEventHandler, addFeaturesEventHandler, addFileUploadOperationsChunkSizeEventHandler, addFileWithProgress, addFolder, addGaTrackingIdEventHandler, addGraphQLReactorClientEventHandler, addIsAddCloudDrivesEnabledEventHandler, addIsAddDriveEnabledEventHandler, addIsAddLocalDrivesEnabledEventHandler, addIsAddPublicDrivesEnabledEventHandler, addIsAnalyticsDatabaseWorkerEnabledEventHandler, addIsAnalyticsEnabledEventHandler, addIsAnalyticsExternalProcessorsEnabledEventHandler, addIsCloudDrivesEnabledEventHandler, addIsDeleteCloudDrivesEnabledEventHandler, addIsDeleteLocalDrivesEnabledEventHandler, addIsDeletePublicDrivesEnabledEventHandler, addIsDiffAnalyticsEnabledEventHandler, addIsDocumentModelSelectionSettingsEnabledEventHandler, addIsDragAndDropEnabledEventHandler, addIsDriveAnalyticsEnabledEventHandler, addIsEditorDebugModeEnabledEventHandler, addIsEditorReadModeEnabledEventHandler, addIsExternalControlsEnabledEventHandler, addIsExternalPackagesEnabledEventHandler, addIsExternalProcessorsEnabledEventHandler, addIsExternalRelationalProcessorsEnabledEventHandler, addIsLocalDrivesEnabledEventHandler, addIsPublicDrivesEnabledEventHandler, addIsRelationalProcessorsEnabledEventHandler, addIsSentryTracingEnabledEventHandler, addLoadingEventHandler, addLocalDrivesEnabledEventHandler, addLogLevelEventHandler, addModalEventHandler, addPHEventHandlers, addPackageDiscoveryServiceEventHandler, addPromiseState, addReactorClientEventHandler, addReactorClientModuleEventHandler, addRemoteDrive, addRenownAdaptersEventHandler, addRenownChainIdEventHandler, addRenownEventHandler, addRenownNetworkIdEventHandler, addRenownUrlEventHandler, addRequiresHardRefreshEventHandler, addResetSelectedNodeEventHandler, addRevisionHistoryVisibleEventHandler, addRouterBasenameEventHandler, addSelectedDriveIdEventHandler, addSelectedNodeIdEventHandler, addSelectedTimelineItemEventHandler, addSelectedTimelineRevisionEventHandler, addSentryDsnEventHandler, addSentryEnvEventHandler, addSentryReleaseEventHandler, addSetSelectedDriveOnPopStateEventHandler, addSetSelectedNodeOnPopStateEventHandler, addStudioModeEventHandler, addSwitchboardUrlEventHandler, addToastEventHandler, addVersionCheckIntervalEventHandler, addVersionEventHandler, addVetraPackageManagerEventHandler, addWarnOutdatedAppEventHandler, ambientRenownTokenProvider, baseDocumentModels, baseDocumentModelsMap, buildDocumentSubgraphQuery, buildDocumentSubgraphUrl, callEventHandlerRegisterFunctions, callGlobalSetterForKey, clearGlobal, closePHModal, commonGlobalEventHandlerFunctions, convertRemoteOperations, createAnalyticsStore, createClient, createProcessorQuery, createUrlWithPreservedParams, deleteDrive, deleteNode, deriveSystemUrl, describeGraphQLDocument, diffStateShapes, dispatchActions, downloadDocument, driveIdFromUrl, dropAllReactorStorage, ensurePHEventHandlers, exportFile, extractDriveIdFromPath, extractDriveIdFromSlug, extractDriveSlugFromPath, extractNodeIdFromPath, extractNodeIdFromSlug, extractNodeSlugFromPath, findUuid, getAnalyticsStore, getDocumentGraphqlQuery, getDocumentUpgradePreview, getDocumentVersionStatus, getDriveIdBySlug, getDrives, getGlobal, getPackagePage, getPackages, getPackagesByDocumentType, getPackagesForDocumentType, getPathWithoutBase, getRevisionFromDate, getSlugFromDriveUrl, getSwitchboardGatewayUrlFromDriveUrl, getSyncStatus, getSyncStatusSync, getUserPermissions, graphqlDocumentEvents, graphqlDocumentsEvents, graphqlEventsToSyncDrive, hasPreloadBandwidth, hideRevisionHistory, identifierFromMutateDocumentOperationVariables, initConnectCrypto, initRenownCrypto, initTheme, isDocumentTypeSupported, isDriveAuthError, isExternalControlsEnabledEventFunctions, isFileNodeKind, isFolderNodeKind, isGraphQLReactorClient, loadFile, loading, login, logout, makeAuthConnectionParams, makeAuthMiddleware, makeDriveUrlComponent, makeNodeSlug, makePHEventFunctions, openRenown, packageFromDocumentModels, parseDriveUrl, phAppConfigHooks, phAppConfigSetters, phDocumentEditorConfigHooks, phDocumentEditorConfigSetters, phDocumentFromGetDocument, phDocumentFromMutation, phDocumentFromQuery, phDocumentsFromQuery, phGlobalConfigHooks, phGlobalConfigSetters, preloadEditorModule, reactorGraphqlBatchFetchDocuments, reactorGraphqlCreateDocument, reactorGraphqlDeleteDocument, reactorGraphqlDeleteDocuments, reactorGraphqlFetchDocument, reactorGraphqlMutateDocument, readPromiseState, refreshReactorData, refreshReactorDataClient, renameDrive, renameDriveNode, resolveUrlPathname, revisionMapFromRevisionsList, setAllowList, setAllowedDocumentTypes, setAnalyticsDatabaseName, setAttachmentService, setBasePath, setCliVersion, setDefaultDrivesUrl, setDefaultPHGlobalConfig, setDisabledEditors, setDocumentCache, setDriveAvailableOffline, setDriveMetadata, setDriveSharingType, setDrives, setDrivesPreserveStrategy, setEnabledEditors, setFeatures, setFileUploadOperationsChunkSize, setGaTrackingId, setGlobal, setGraphQLReactorClient, setIsAddCloudDrivesEnabled, setIsAddDriveEnabled, setIsAddLocalDrivesEnabled, setIsAddPublicDrivesEnabled, setIsAnalyticsDatabaseWorkerEnabled, setIsAnalyticsEnabled, setIsAnalyticsExternalProcessorsEnabled, setIsCloudDrivesEnabled, setIsDeleteCloudDrivesEnabled, setIsDeleteLocalDrivesEnabled, setIsDeletePublicDrivesEnabled, setIsDiffAnalyticsEnabled, setIsDocumentModelSelectionSettingsEnabled, setIsDragAndDropEnabled, setIsDriveAnalyticsEnabled, setIsEditorDebugModeEnabled, setIsEditorReadModeEnabled, setIsExternalControlsEnabled, setIsExternalPackagesEnabled, setIsExternalProcessorsEnabled, setIsExternalRelationalProcessorsEnabled, setIsLocalDrivesEnabled, setIsPublicDrivesEnabled, setIsRelationalProcessorsEnabled, setIsSentryTracingEnabled, setLoading, setLocalDrivesEnabled, setLogLevel, setPGliteDB, setPHAppConfig, setPHAppConfigByKey, setPHDocumentEditorConfig, setPHDocumentEditorConfigByKey, setPHGlobalConfig, setPHGlobalConfigByKey, setPHModal, setPHToast, setPackageDiscoveryService, setReactorClient, setReactorClientModule, setRenown, setRenownAdapters, setRenownChainId, setRenownNetworkId, setRenownUrl, setRequiresHardRefresh, setRevisionHistoryVisible, setRouterBasename, setSelectedDrive, setSelectedDriveId, setSelectedNode, setSelectedTimelineItem, setSelectedTimelineRevision, setSentryDsn, setSentryEnv, setSentryRelease, setStudioMode, setSwitchboardUrl, setVersion, setVersionCheckInterval, setVetraPackageManager, setWarnOutdatedApp, showCreateDocumentModal, showDeleteNodeModal, showPHModal, showRevisionHistory, signStampedAction, sortNodesByName, stampAction, startDocumentChangesSubscription, subgraphUrlFromGraphqlUrl, subscriptionsUrlFromGraphqlUrl, trimTrailingSlash, truncateAllTables, upgradeDocument, useAllowList, useAllowedDocumentModelModules, useAllowedDocumentTypes, useAnalyticsDatabaseName, useAppModuleById, useAppModules, useAttachmentPreview, useAttachmentService, useAttachmentUpload, useAttachments, useBasePath, useCliVersion, useConnectionState, useConnectionStates, useDatabase, useDefaultAppModule, useDefaultDrivesUrl, useDid, useDisabledEditors, useDispatch, useDocument, useDocumentById, useDocumentCache, useDocumentModelModuleById, useDocumentModelModules, useDocumentOfType, useDocumentOperations, useDocumentSafe, useDocumentTypes, useDocumentTypesInSelectedDrive, useDocumentVersionStatus, useDocuments, useDocumentsByIds, useDocumentsInSelectedDrive, useDocumentsInSelectedFolder, useDownloadDocument, useDragNode, useDriveById, useDriveSystemInfo, useDrives, useDrivesPreserveStrategy, useDropFile, useDropNode, useEditorFileDrop, useEditorModuleById, useEditorModules, useEditorModulesForDocumentType, useEditorPreloader, useEnabledEditors, useFallbackEditorModule, useFeatures, useFileNodesInSelectedDrive, useFileNodesInSelectedFolder, useFileUploadOperationsChunkSize, useFolderById, useFolderNodesInSelectedDrive, useFolderNodesInSelectedFolder, useGaTrackingId, useGetDocument, useGetDocumentAsync, useGetDocuments, useGetSwitchboardLink, useGraphQLReactorClient, useInitReactorGraphqlClient, useIsAddCloudDrivesEnabled, useIsAddDriveEnabled, useIsAddLocalDrivesEnabled, useIsAddPublicDrivesEnabled, useIsAnalyticsDatabaseWorkerEnabled, useIsAnalyticsEnabled, useIsAnalyticsExternalProcessorsEnabled, useIsCloudDrivesEnabled, useIsDeleteCloudDrivesEnabled, useIsDeleteLocalDrivesEnabled, useIsDeletePublicDrivesEnabled, useIsDiffAnalyticsEnabled, useIsDocumentModelSelectionSettingsEnabled, useIsDragAndDropEnabled, useIsDriveAnalyticsEnabled, useIsEditorDebugModeEnabled, useIsEditorReadModeEnabled, useIsExternalControlsEnabled, useIsExternalPackagesEnabled, useIsExternalProcessorsEnabled, useIsExternalRelationalProcessorsEnabled, useIsLocalDrivesEnabled, useIsPublicDrivesEnabled, useIsRelationalProcessorsEnabled, useIsSentryTracingEnabled, useLoading, useLocalDrivesEnabled, useLogLevel, useLoginStatus, useModelRegistry, useNodeActions, useNodeById, useNodeParentFolderById, useNodePathById, useNodesInSelectedDrive, useNodesInSelectedDriveOrFolder, useNodesInSelectedFolder, useOnDropFile, usePGlite, usePHAppConfigByKey, usePHDocumentEditorConfigByKey, usePHGlobalConfigByKey, usePHModal, usePHToast, usePackageDiscoveryService, useParentFolderForSelectedNode, useReactorClient, useReactorClientModule, useRelationalDb, useRelationalQuery, useRenown, useRenownAdapters, useRenownAuth, useRenownAuthAsync, useRenownChainId, useRenownInit, useRenownInitialAuth, useRenownInitialUser, useRenownLoginMethods, useRenownNetworkId, useRenownSessionCookie, useRenownSessionSynced, useRenownUrl, useRequiresHardRefresh, useResetPHGlobalConfig, useRevisionHistoryVisible, useRouterBasename, useSelectedDocument, useSelectedDocumentId, useSelectedDocumentOfType, useSelectedDocumentSafe, useSelectedDrive, useSelectedDriveId, useSelectedDriveSafe, useSelectedFolder, useSelectedNode, useSelectedNodePath, useSelectedTimelineItem, useSelectedTimelineRevision, useSentryDsn, useSentryEnv, useSentryRelease, useSetDefaultPHGlobalConfig, useSetPHAppConfig, useSetPHDocumentEditorConfig, useSetPHGlobalConfig, useStudioMode, useSubgraphModules, useSupportedDocumentTypesInReactor, useSwitchboardClient, useSwitchboardUrl, useSync, useSyncList, useTheme, useUser, useUserPermissions, useVersion, useVersionCheckInterval, useVetraPackageManager, useVetraPackages, useWarnOutdatedApp, validateDocument, viewFilterInputFromViewFilter, waitForDocumentReady };
3864
2493
 
3865
2494
  //# sourceMappingURL=index.js.map