@powerhousedao/reactor-browser 6.2.2-dev.6 → 6.2.2-dev.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +283 -0
- package/dist/attachment-service-DTFJRf5j.d.ts +1057 -0
- package/dist/attachment-service-DTFJRf5j.d.ts.map +1 -0
- package/dist/{client-_Gh2Uf0E.js → client-DB8gP4hz.js} +79 -13
- package/dist/client-DB8gP4hz.js.map +1 -0
- package/dist/client-DjkEpwu_.d.ts +14 -0
- package/dist/client-DjkEpwu_.d.ts.map +1 -0
- package/dist/{client-u13cr-Vg.js → client-Zz_l9QzI.js} +30 -3
- package/dist/client-Zz_l9QzI.js.map +1 -0
- package/dist/{document-by-id-dLYFX-xz.js → document-by-id-BSZqTN66.js} +81 -51
- package/dist/document-by-id-BSZqTN66.js.map +1 -0
- package/dist/document-operations-C6nce9dH.js +2928 -0
- package/dist/document-operations-C6nce9dH.js.map +1 -0
- package/dist/global-pg5gy2eZ.d.ts +400 -0
- package/dist/global-pg5gy2eZ.d.ts.map +1 -0
- package/dist/index-CxxxP14A.d.ts +144 -0
- package/dist/index-CxxxP14A.d.ts.map +1 -0
- package/dist/index-DjloxNSR.d.ts +345 -0
- package/dist/index-DjloxNSR.d.ts.map +1 -0
- package/dist/index.d.ts +305 -709
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +608 -1660
- package/dist/index.js.map +1 -1
- package/dist/{inspector-proxy-CvQDDxmT.d.ts → inspector-proxy-CaCFdEG4.d.ts} +4 -2
- package/dist/inspector-proxy-CaCFdEG4.d.ts.map +1 -0
- package/dist/{make-ph-event-functions-BHoLPif5.js → make-ph-event-functions-DBq3iWYn.js} +1 -1
- package/dist/{make-ph-event-functions-BHoLPif5.js.map → make-ph-event-functions-DBq3iWYn.js.map} +1 -1
- package/dist/{index-DS4W07Y8.d.ts → pglite-CntadC_p-BtEalg1H.d.ts} +2 -142
- package/dist/pglite-CntadC_p-BtEalg1H.d.ts.map +1 -0
- package/dist/{relational-Dj06-YkI.js → relational-C_0GdGVN.js} +2 -2
- package/dist/{relational-Dj06-YkI.js.map → relational-C_0GdGVN.js.map} +1 -1
- package/dist/renown-BZabzj4l.js +68 -0
- package/dist/renown-BZabzj4l.js.map +1 -0
- package/dist/{renown-D-1c_Bvx.js → renown-C7a1ygsj.js} +471 -57
- package/dist/renown-C7a1ygsj.js.map +1 -0
- package/dist/src/analytics/index.d.ts +1 -1
- package/dist/src/analytics/index.js +2 -1
- package/dist/src/analytics/index.js.map +1 -1
- package/dist/src/graphql/client.d.ts +3 -2
- package/dist/src/graphql/client.js +1 -1
- package/dist/src/graphql-client/entry.d.ts +4 -0
- package/dist/src/graphql-client/entry.js +3 -0
- package/dist/src/relational/index.d.ts +1 -1
- package/dist/src/relational/index.js +1 -1
- package/dist/src/renown/index.d.ts +2 -2
- package/dist/src/renown/index.js +3 -2
- package/dist/src/rpc/index.d.ts +6 -3
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/src/rpc/index.js +41 -10
- package/dist/src/rpc/index.js.map +1 -1
- package/dist/store-DAJq6vSs.js +37 -0
- package/dist/store-DAJq6vSs.js.map +1 -0
- package/dist/{client-09xv0Dq6.d.ts → types-4rfAFZQd.d.ts} +87 -19
- package/dist/types-4rfAFZQd.d.ts.map +1 -0
- package/dist/{types-CPV0Cnsy.d.ts → types-wGaiXwjh.d.ts} +1 -1
- package/dist/{types-CPV0Cnsy.d.ts.map → types-wGaiXwjh.d.ts.map} +1 -1
- package/package.json +16 -10
- package/dist/client-09xv0Dq6.d.ts.map +0 -1
- package/dist/client-_Gh2Uf0E.js.map +0 -1
- package/dist/client-u13cr-Vg.js.map +0 -1
- package/dist/document-by-id-dLYFX-xz.js.map +0 -1
- package/dist/index-D3bV5rcl.d.ts +0 -216
- package/dist/index-D3bV5rcl.d.ts.map +0 -1
- package/dist/index-DS4W07Y8.d.ts.map +0 -1
- package/dist/inspector-proxy-CvQDDxmT.d.ts.map +0 -1
- package/dist/renown-D-1c_Bvx.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,580 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
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-BSZqTN66.js";
|
|
2
|
+
import { $ as useGraphQLReactorClient, $i as ReactorOperationFieldsFragmentDoc, $n as setIsDeletePublicDrivesEnabled, $r as useIsEditorReadModeEnabled, $t as addIsCloudDrivesEnabledEventHandler, A as isFolderNodeKind, Aa as showPHModal, Ai as phDocumentEditorConfigSetters, An as addWarnOutdatedAppEventHandler, Ar as useBasePath, At as addFeaturesEventHandler, B as setReactorClientModule, Bi as makeAuthConnectionParams, Bn as setEnabledEditors, Br as useIsAddLocalDrivesEnabled, Bt as addDefaultDrivesUrlEventHandler, C as useSelectedNode, Ca as getUserPermissions, Ci as addAllowedDocumentTypesEventHandler, Cn as addSentryDsnEventHandler, Cr as setStudioMode, Ct as extractNodeIdFromSlug, D as useFolderNodesInSelectedDrive, Da as setPHModal, Di as phAppConfigHooks, Dn as addSwitchboardUrlEventHandler, Dr as setWarnOutdatedApp, Dt as makeDriveUrlComponent, E as useFileNodesInSelectedDrive, Ea as closePHModal, Ei as isExternalControlsEnabledEventFunctions, En as addStudioModeEventHandler, Er as setVersionCheckInterval, Et as getPathWithoutBase, F as showRevisionHistory, Fa as NoSelectedDocumentError, Fi as useIsDragAndDropEnabled, Fn as setBasePath, Fr as useEnabledEditors, Ft as useAttachmentService, G as useReactorClientModule, Gi as subgraphUrlFromGraphqlUrl, Gn as setIsAddLocalDrivesEnabled, Gr as useIsCloudDrivesEnabled, Gt as addGaTrackingIdEventHandler, H as useModelRegistry, Hi as subscriptionsUrlFromGraphqlUrl, Hn as setGaTrackingId, Hr as useIsAnalyticsDatabaseWorkerEnabled, Ht as addDrivesPreserveStrategyEventHandler, I as useRevisionHistoryVisible, Ia as UnsupportedDocumentTypeError, Ii as useIsExternalControlsEnabled, In as setCliVersion, Ir as useFileUploadOperationsChunkSize, It as addAllowListEventHandler, J as addPackageDiscoveryServiceEventHandler, Ji as resolveDocumentModelModule, Jn as setIsAnalyticsEnabled, Jr as useIsDeletePublicDrivesEnabled, Jt as addIsAddLocalDrivesEnabledEventHandler, K as useSync, Ki as StaticPackageManager, Kn as setIsAddPublicDrivesEnabled, Kr as useIsDeleteCloudDrivesEnabled, Kt as addIsAddCloudDrivesEnabledEventHandler, L as addReactorClientEventHandler, Li as GraphQLReactorClient, Ln as setDefaultDrivesUrl, Lr as useGaTrackingId, Lt as addAnalyticsDatabaseNameEventHandler, M as addRevisionHistoryVisibleEventHandler, Ma as DocumentModelNotFoundError, Mi as setIsDragAndDropEnabled, Mn as phGlobalConfigSetters, Mr as useDefaultDrivesUrl, Mt as useFeatures, N as hideRevisionHistory, Na as DocumentNotFoundError, Ni as setIsExternalControlsEnabled, Nn as setAllowList, Nr as useDisabledEditors, Nt as addAttachmentServiceEventHandler, O as useNodesInSelectedDrive, Oa as showCreateDocumentModal, Oi as phAppConfigSetters, On as addVersionCheckIntervalEventHandler, Or as useAllowList, Ot as makeNodeSlug, P as setRevisionHistoryVisible, Pa as DocumentTypeMismatchError, Pi as useAllowedDocumentTypes, Pn as setAnalyticsDatabaseName, Pr as useDrivesPreserveStrategy, Pt as setAttachmentService, Q as setGraphQLReactorClient, Qi as MutateDocumentWithOperationsDocument, Qn as setIsDeleteLocalDrivesEnabled, Qr as useIsEditorDebugModeEnabled, Qt as addIsAnalyticsExternalProcessorsEnabledEventHandler, R as addReactorClientModuleEventHandler, Ri as isGraphQLReactorClient, Rn as setDisabledEditors, Rr as useIsAddCloudDrivesEnabled, Rt as addBasePathEventHandler, S as useSelectedTimelineItem, Sa as upgradeDocument, Si as useWarnOutdatedApp, Sn as addRouterBasenameEventHandler, Sr as setSentryRelease, St as extractNodeIdFromPath, T as useDocumentsInSelectedDrive, Ta as addModalEventHandler, Ti as addIsExternalControlsEnabledEventHandler, Tn as addSentryReleaseEventHandler, Tr as setVersion, Tt as findUuid, U as usePGlite, Ui as SubgraphSdkRegistry, Un as setIsAddCloudDrivesEnabled, Ur as useIsAnalyticsEnabled, Ut as addEnabledEditorsEventHandler, V as useDatabase, Vi as startDocumentChangesSubscription, Vn as setFileUploadOperationsChunkSize, Vr as useIsAddPublicDrivesEnabled, Vt as addDisabledEditorsEventHandler, W as useReactorClient, Wi as describeGraphQLDocument, Wn as setIsAddDriveEnabled, Wr as useIsAnalyticsExternalProcessorsEnabled, Wt as addFileUploadOperationsChunkSizeEventHandler, X as usePackageDiscoveryService, Xi as signStampedAction, Xn as setIsCloudDrivesEnabled, Xr as useIsDocumentModelSelectionSettingsEnabled, Xt as addIsAnalyticsDatabaseWorkerEnabledEventHandler, Y as setPackageDiscoveryService, Yi as prepareSignedActions, Yn as setIsAnalyticsExternalProcessorsEnabled, Yr as useIsDiffAnalyticsEnabled, Yt as addIsAddPublicDrivesEnabledEventHandler, Z as addGraphQLReactorClientEventHandler, Zi as stampAction, Zn as setIsDeleteCloudDrivesEnabled, Zr as useIsDriveAnalyticsEnabled, Zt as addIsAnalyticsEnabledEventHandler, _ as addSelectedTimelineRevisionEventHandler, _a as exportFile, _i as useSentryRelease, _n as addRenownAdaptersEventHandler, _r as setRenownUrl, _t as useDrives, a as ensurePHEventHandlers, aa as ConflictError, ai as useIsRelationalProcessorsEnabled, an as addIsDriveAnalyticsEnabledEventHandler, ar as setIsExternalPackagesEnabled, at as addSetSelectedDriveOnPopStateEventHandler, b as addSelectedTimelineItemEventHandler, ba as renameDriveNode, bi as useVersion, bn as addRenownUrlEventHandler, br as setSentryDsn, bt as extractDriveIdFromSlug, c as callEventHandlerRegisterFunctions, ca as extractRevisionMap, ci as useLogLevel, cn as addIsExternalPackagesEnabledEventHandler, cr as setIsLocalDrivesEnabled, ct as useSelectedDrive, d as setVetraPackageManager, da as addDocument, di as useRenownNetworkId, dn as addIsLocalDrivesEnabledEventHandler, dr as setIsSentryTracingEnabled, dt as addResetSelectedNodeEventHandler, ea as ambientRenownTokenProvider, ei as useIsExternalPackagesEnabled, en as addIsDeleteCloudDrivesEnabledEventHandler, er as setIsDiffAnalyticsEnabled, et as addDraggingNodeEventHandler, f as useVetraPackageManager, fa as addFile, fi as useRenownUrl, fn as addIsPublicDrivesEnabledEventHandler, fr as setLocalDrivesEnabled, ft as addSelectedNodeIdEventHandler, g as usePHToast, ga as deleteNode, gi as useSentryEnv, gn as addLogLevelEventHandler, gr as setRenownNetworkId, gt as setDrives, h as setPHToast, ha as copyNode$1, hi as useSentryDsn, hn as addLocalDrivesEnabledEventHandler, hr as setRenownChainId, ht as addDrivesEventHandler, i as GraphQLReactorProvider, ia as revisionMapFromRevisionsList, ii as useIsPublicDrivesEnabled, in as addIsDocumentModelSelectionSettingsEnabledEventHandler, ir as setIsEditorReadModeEnabled, it as addSelectedDriveIdEventHandler, j as sortNodesByName, ja as usePHModal, ji as setAllowedDocumentTypes, jn as phGlobalConfigHooks, jr as useCliVersion, jt as setFeatures, k as isFileNodeKind, ka as showDeleteNodeModal, ki as phDocumentEditorConfigHooks, kn as addVersionEventHandler, kr as useAnalyticsDatabaseName, kt as resolveUrlPathname, l as commonGlobalEventHandlerFunctions, la as hasRevisionConflict, li as useRenownAdapters, ln as addIsExternalProcessorsEnabledEventHandler, lr as setIsPublicDrivesEnabled, lt as useSelectedDriveId, m as addToastEventHandler, ma as addFolder, mi as useRouterBasename, mn as addIsSentryTracingEnabledEventHandler, mr as setRenownAdapters, mt as setSelectedNode, n as useDocumentModelModuleById, na as phDocumentFromGetDocument, ni as useIsExternalRelationalProcessorsEnabled, nn as addIsDeletePublicDrivesEnabledEventHandler, nr as setIsDriveAnalyticsEnabled, nt as useDropNode, o as useSwitchboardClient, oa as buildPulledDocument, oi as useIsSentryTracingEnabled, on as addIsEditorDebugModeEnabledEventHandler, or as setIsExternalProcessorsEnabled, ot as setSelectedDrive, p as useVetraPackages, pa as addFileWithProgress, pi as useRequiresHardRefresh, pn as addIsRelationalProcessorsEnabledEventHandler, pr as setLogLevel, pt as addSetSelectedNodeOnPopStateEventHandler, q as useSyncList, qi as packageFromDocumentModels, qn as setIsAnalyticsDatabaseWorkerEnabled, qr as useIsDeleteLocalDrivesEnabled, qt as addIsAddDriveEnabledEventHandler, r as useDocumentModelModules, ra as phDocumentFromMutation, ri as useIsLocalDrivesEnabled, rn as addIsDiffAnalyticsEnabledEventHandler, rr as setIsEditorDebugModeEnabled, rt as useDropTarget, s as addPHEventHandlers, sa as convertRemoteOperations, si as useLocalDrivesEnabled, sn as addIsEditorReadModeEnabledEventHandler, sr as setIsExternalRelationalProcessorsEnabled, st as setSelectedDriveId, t as useDocumentOperations, ta as makeAuthMiddleware, ti as useIsExternalProcessorsEnabled, tn as addIsDeleteLocalDrivesEnabledEventHandler, tr as setIsDocumentModelSelectionSettingsEnabled, tt as useDragNode, u as addVetraPackageManagerEventHandler, ua as screamingSnakeToCamel, ui as useRenownChainId, un as addIsExternalRelationalProcessorsEnabledEventHandler, ur as setIsRelationalProcessorsEnabled, ut as useSelectedDriveSafe, v as setSelectedTimelineRevision, va as loadFile, vi as useStudioMode, vn as addRenownChainIdEventHandler, vr as setRequiresHardRefresh, vt as createUrlWithPreservedParams, w as useDocumentTypesInSelectedDrive, wa as isDocumentTypeSupported, wi as addIsDragAndDropEnabledEventHandler, wn as addSentryEnvEventHandler, wr as setSwitchboardUrl, wt as extractNodeSlugFromPath, x as setSelectedTimelineItem, xa as renameNode, xi as useVersionCheckInterval, xn as addRequiresHardRefreshEventHandler, xr as setSentryEnv, xt as extractDriveSlugFromPath, y as useSelectedTimelineRevision, ya as moveNode$1, yi as useSwitchboardUrl, yn as addRenownNetworkIdEventHandler, yr as setRouterBasename, yt as extractDriveIdFromPath, z as setReactorClient, zi as viewFilterInputFromViewFilter, zn as setDrivesPreserveStrategy, zr as useIsAddDriveEnabled, zt as addCliVersionEventHandler } from "./document-operations-C6nce9dH.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 {
|
|
5
|
-
import {
|
|
6
|
-
import { i as
|
|
7
|
-
import { i as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { DriveDocumentSchema,
|
|
11
|
-
import { allPass,
|
|
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-DB8gP4hz.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 { toTransportAction, 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 { AuthEnforcementDisabledError, 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?.
|
|
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?.
|
|
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 = [];
|
|
@@ -2706,6 +1240,138 @@ function useTheme() {
|
|
|
2706
1240
|
};
|
|
2707
1241
|
}
|
|
2708
1242
|
//#endregion
|
|
1243
|
+
//#region src/hooks/use-can-execute.ts
|
|
1244
|
+
const IDLE = { status: "idle" };
|
|
1245
|
+
const LOADING = { status: "loading" };
|
|
1246
|
+
const UNSUPPORTED = { status: "unsupported" };
|
|
1247
|
+
function readyState(answer) {
|
|
1248
|
+
return {
|
|
1249
|
+
status: "ready",
|
|
1250
|
+
evaluations: answer.evaluations,
|
|
1251
|
+
allAllowed: answer.allAllowed,
|
|
1252
|
+
anyAllowed: answer.anyAllowed,
|
|
1253
|
+
allDenied: answer.allDenied,
|
|
1254
|
+
anyDenied: answer.anyDenied
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Whether the subject the reactor client would decide for now is the one it is
|
|
1259
|
+
* going to keep.
|
|
1260
|
+
*
|
|
1261
|
+
* Renown's login status is the signal. Only `checking` is transient --
|
|
1262
|
+
* mid-login, about to resolve -- and `authorized` without a user yet is still
|
|
1263
|
+
* mid-resolution. Everything else is a steady state: `initial` is the anonymous
|
|
1264
|
+
* subject for a user who never logged in or just logged out (a restored session
|
|
1265
|
+
* is `authorized` from construction, so `initial` is not a pre-login window),
|
|
1266
|
+
* and `not-authorized` is a failed login, anonymous too.
|
|
1267
|
+
*
|
|
1268
|
+
* An absent status counts as unsettled, which is one render in a host that wires
|
|
1269
|
+
* renown -- and forever in a host that does not. Such a host names its subject
|
|
1270
|
+
* through the `subject` parameter instead, which needs nothing to settle.
|
|
1271
|
+
*/
|
|
1272
|
+
function subjectSettled(loginStatus, user) {
|
|
1273
|
+
if (loginStatus === "authorized") return user !== void 0;
|
|
1274
|
+
return loginStatus === "initial" || loginStatus === "not-authorized";
|
|
1275
|
+
}
|
|
1276
|
+
/**
|
|
1277
|
+
* Predicts whether the current subject may execute each of a set of candidate
|
|
1278
|
+
* operations on one document, so a UI can disable a control rather than offer an
|
|
1279
|
+
* action that fails on submit.
|
|
1280
|
+
*
|
|
1281
|
+
* The answer is a prediction and not a promise: the submit path is the only
|
|
1282
|
+
* authority, and this cannot reproduce the append condition real admission
|
|
1283
|
+
* compiles. Treat an allow as "worth offering", never as "will succeed", and
|
|
1284
|
+
* keep handling the submit's refusal.
|
|
1285
|
+
*
|
|
1286
|
+
* A candidate whose verdict depends on its input has to carry that input, since
|
|
1287
|
+
* a conditional grant reads it. A candidate standing for a form the user has not
|
|
1288
|
+
* filled in yet predicts the verdict an empty form earns.
|
|
1289
|
+
*
|
|
1290
|
+
* Deliberately reads the client off the reactor client module rather than
|
|
1291
|
+
* through `useReactorClient`: the latter hands back the minimal browser client
|
|
1292
|
+
* contract, which does not carry the preflight, and the plain-GraphQL setup that
|
|
1293
|
+
* implements it sets no module at all. No module therefore reports
|
|
1294
|
+
* `unsupported`.
|
|
1295
|
+
*
|
|
1296
|
+
* Re-evaluated when the document's revision moves, which covers a policy change
|
|
1297
|
+
* written to the document being asked about. Two gaps are known and accepted:
|
|
1298
|
+
*
|
|
1299
|
+
* - A group membership change is a write to the *group* document, so it fires no
|
|
1300
|
+
* change event for this one. A group-gated grant can therefore be stale here
|
|
1301
|
+
* until something else re-evaluates.
|
|
1302
|
+
* - A change event carries no scope, so any write to the document re-evaluates,
|
|
1303
|
+
* including one that cannot affect a verdict.
|
|
1304
|
+
*
|
|
1305
|
+
* @param documentId - The document the candidates target, or null/undefined to stay idle
|
|
1306
|
+
* @param candidates - Operations to predict a verdict for. Read by content, so an inline array is fine
|
|
1307
|
+
* @param branch - Branch to evaluate against, defaulting to main
|
|
1308
|
+
* @param subject - Optional subject to decide for instead of the client's signer
|
|
1309
|
+
*/
|
|
1310
|
+
function useCanExecute(documentId, candidates, branch = "main", subject) {
|
|
1311
|
+
const client = useReactorClientModule()?.client;
|
|
1312
|
+
const loginStatus = useLoginStatus();
|
|
1313
|
+
const user = useUser();
|
|
1314
|
+
const revision = useDocumentSafe(documentId).data?.header.revision;
|
|
1315
|
+
const [nonce, setNonce] = useState(0);
|
|
1316
|
+
const [state, setState] = useState(IDLE);
|
|
1317
|
+
const candidateKey = JSON.stringify(candidates);
|
|
1318
|
+
const subjectKey = JSON.stringify(subject);
|
|
1319
|
+
const stableCandidates = useMemo(() => candidates, [candidateKey]);
|
|
1320
|
+
const stableSubject = useMemo(() => subject, [subjectKey]);
|
|
1321
|
+
const settled = subject !== void 0 || subjectSettled(loginStatus, user);
|
|
1322
|
+
const subjectIdentity = subject !== void 0 ? subjectKey : `${loginStatus ?? ""}:${user?.address ?? ""}`;
|
|
1323
|
+
const revisionKey = JSON.stringify(revision);
|
|
1324
|
+
const refetch = useCallback(() => {
|
|
1325
|
+
setNonce((count) => count + 1);
|
|
1326
|
+
}, []);
|
|
1327
|
+
useEffect(() => {
|
|
1328
|
+
if (client === void 0) {
|
|
1329
|
+
setState(UNSUPPORTED);
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
if (!documentId) {
|
|
1333
|
+
setState(IDLE);
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
if (!settled) {
|
|
1337
|
+
setState(LOADING);
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
let active = true;
|
|
1341
|
+
setState(LOADING);
|
|
1342
|
+
const evaluate = async () => {
|
|
1343
|
+
let next;
|
|
1344
|
+
try {
|
|
1345
|
+
next = readyState(await client.evaluateActions(documentId, branch, stableCandidates, stableSubject));
|
|
1346
|
+
} catch (error) {
|
|
1347
|
+
next = AuthEnforcementDisabledError.isError(error) ? UNSUPPORTED : {
|
|
1348
|
+
status: "error",
|
|
1349
|
+
error: Error.isError(error) ? error : new Error(String(error))
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
if (active) setState(next);
|
|
1353
|
+
};
|
|
1354
|
+
evaluate();
|
|
1355
|
+
return () => {
|
|
1356
|
+
active = false;
|
|
1357
|
+
};
|
|
1358
|
+
}, [
|
|
1359
|
+
client,
|
|
1360
|
+
documentId,
|
|
1361
|
+
branch,
|
|
1362
|
+
stableCandidates,
|
|
1363
|
+
stableSubject,
|
|
1364
|
+
settled,
|
|
1365
|
+
subjectIdentity,
|
|
1366
|
+
revisionKey,
|
|
1367
|
+
nonce
|
|
1368
|
+
]);
|
|
1369
|
+
return {
|
|
1370
|
+
...state,
|
|
1371
|
+
refetch
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
//#endregion
|
|
2709
1375
|
//#region src/hooks/use-drive-system-info.ts
|
|
2710
1376
|
function deriveSystemUrl(channelUrl) {
|
|
2711
1377
|
try {
|
|
@@ -2909,6 +1575,116 @@ function buildDocumentSubgraphUrl(driveUrl, identifier, authToken) {
|
|
|
2909
1575
|
return `${driveUrl}?explorerURLState=${buildDocumentSubgraphQuery(identifier, authToken)}`;
|
|
2910
1576
|
}
|
|
2911
1577
|
//#endregion
|
|
1578
|
+
//#region src/utils/upgrade-preview.ts
|
|
1579
|
+
const NON_DOMAIN_SCOPES = new Set(["auth", "document"]);
|
|
1580
|
+
function isPlainObject(value) {
|
|
1581
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1582
|
+
}
|
|
1583
|
+
function walkShapes(before, after, path, added, removed) {
|
|
1584
|
+
if (isPlainObject(before) && isPlainObject(after)) {
|
|
1585
|
+
const beforeKeys = Object.keys(before);
|
|
1586
|
+
const afterKeys = Object.keys(after);
|
|
1587
|
+
for (const key of afterKeys) {
|
|
1588
|
+
const childPath = path ? `${path}.${key}` : key;
|
|
1589
|
+
if (!beforeKeys.includes(key)) {
|
|
1590
|
+
added.push(childPath);
|
|
1591
|
+
continue;
|
|
1592
|
+
}
|
|
1593
|
+
walkShapes(before[key], after[key], childPath, added, removed);
|
|
1594
|
+
}
|
|
1595
|
+
for (const key of beforeKeys) if (!afterKeys.includes(key)) removed.push(path ? `${path}.${key}` : key);
|
|
1596
|
+
return;
|
|
1597
|
+
}
|
|
1598
|
+
if (Array.isArray(before) && Array.isArray(after)) {
|
|
1599
|
+
if (before.length > 0 && after.length > 0) walkShapes(before[0], after[0], `${path}[]`, added, removed);
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* Recursively diffs the structural shape of two values, returning dot-paths
|
|
1604
|
+
* of keys present in `after` but not `before` (added) and vice versa
|
|
1605
|
+
* (removed). Array fields are compared by the shape of a representative
|
|
1606
|
+
* element (the first element on each side, when both sides have one) using
|
|
1607
|
+
* the `path[]` notation, e.g. `todos[].status`. Only key presence is
|
|
1608
|
+
* compared — array length and primitive values are ignored.
|
|
1609
|
+
*/
|
|
1610
|
+
function diffStateShapes(before, after) {
|
|
1611
|
+
const added = [];
|
|
1612
|
+
const removed = [];
|
|
1613
|
+
walkShapes(before, after, "", added, removed);
|
|
1614
|
+
return {
|
|
1615
|
+
added,
|
|
1616
|
+
removed
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* Computes a dry-run preview of upgrading `document` to the latest
|
|
1621
|
+
* registered version of its document model: the version jump, the upgrade
|
|
1622
|
+
* steps that will run, and which state fields will be added or removed.
|
|
1623
|
+
* Applies the upgrade reducers against a deep clone of the document, so the
|
|
1624
|
+
* original is left untouched.
|
|
1625
|
+
*
|
|
1626
|
+
* Returns undefined when the registry is unavailable, the document is
|
|
1627
|
+
* already at (or above) the latest registered version, or the upgrade path
|
|
1628
|
+
* cannot be computed.
|
|
1629
|
+
*/
|
|
1630
|
+
function getDocumentUpgradePreview(document, registry) {
|
|
1631
|
+
if (!registry) return;
|
|
1632
|
+
const documentType = document.header.documentType;
|
|
1633
|
+
const fromVersion = document.state.document.version || 1;
|
|
1634
|
+
let latestVersion;
|
|
1635
|
+
try {
|
|
1636
|
+
latestVersion = registry.getLatestVersion(documentType);
|
|
1637
|
+
} catch {
|
|
1638
|
+
return;
|
|
1639
|
+
}
|
|
1640
|
+
if (fromVersion >= latestVersion) return;
|
|
1641
|
+
let transitions;
|
|
1642
|
+
try {
|
|
1643
|
+
transitions = registry.computeUpgradePath(documentType, fromVersion, latestVersion);
|
|
1644
|
+
} catch {
|
|
1645
|
+
return;
|
|
1646
|
+
}
|
|
1647
|
+
const stubAction = {
|
|
1648
|
+
id: "",
|
|
1649
|
+
type: "UPGRADE_DOCUMENT",
|
|
1650
|
+
scope: "document",
|
|
1651
|
+
timestampUtcMs: "",
|
|
1652
|
+
input: {
|
|
1653
|
+
documentId: document.header.id,
|
|
1654
|
+
model: documentType,
|
|
1655
|
+
fromVersion,
|
|
1656
|
+
toVersion: latestVersion
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
let upgraded = structuredClone(document);
|
|
1660
|
+
try {
|
|
1661
|
+
for (const transition of transitions) upgraded = transition.upgradeReducer(upgraded, stubAction);
|
|
1662
|
+
} catch {
|
|
1663
|
+
return;
|
|
1664
|
+
}
|
|
1665
|
+
const addedFields = [];
|
|
1666
|
+
const removedFields = [];
|
|
1667
|
+
const scopes = new Set([...Object.keys(document.state), ...Object.keys(upgraded.state)]);
|
|
1668
|
+
for (const scope of scopes) {
|
|
1669
|
+
if (NON_DOMAIN_SCOPES.has(scope)) continue;
|
|
1670
|
+
const beforeScope = document.state[scope];
|
|
1671
|
+
const afterScope = upgraded.state[scope];
|
|
1672
|
+
const { added, removed } = diffStateShapes(beforeScope, afterScope);
|
|
1673
|
+
for (const path of added) addedFields.push(`${scope}.${path}`);
|
|
1674
|
+
for (const path of removed) removedFields.push(`${scope}.${path}`);
|
|
1675
|
+
}
|
|
1676
|
+
return {
|
|
1677
|
+
fromVersion,
|
|
1678
|
+
toVersion: latestVersion,
|
|
1679
|
+
steps: transitions.map((transition) => ({
|
|
1680
|
+
toVersion: transition.toVersion,
|
|
1681
|
+
description: transition.description ?? ""
|
|
1682
|
+
})),
|
|
1683
|
+
addedFields,
|
|
1684
|
+
removedFields
|
|
1685
|
+
};
|
|
1686
|
+
}
|
|
1687
|
+
//#endregion
|
|
2912
1688
|
//#region src/hooks/use-get-switchboard-link.ts
|
|
2913
1689
|
/**
|
|
2914
1690
|
* Hook that returns a function to generate a document's switchboard URL.
|
|
@@ -2990,58 +1766,323 @@ function useUserPermissions() {
|
|
|
2990
1766
|
};
|
|
2991
1767
|
}
|
|
2992
1768
|
//#endregion
|
|
1769
|
+
//#region src/hooks/attachment-progress.ts
|
|
1770
|
+
const IDLE_PROGRESS = {
|
|
1771
|
+
percent: 0,
|
|
1772
|
+
loaded: 0,
|
|
1773
|
+
total: void 0,
|
|
1774
|
+
indeterminate: false
|
|
1775
|
+
};
|
|
1776
|
+
function toProgressState(progress) {
|
|
1777
|
+
return {
|
|
1778
|
+
percent: toPercent(progress),
|
|
1779
|
+
loaded: progress.loaded,
|
|
1780
|
+
total: progress.total,
|
|
1781
|
+
indeterminate: progress.indeterminate
|
|
1782
|
+
};
|
|
1783
|
+
}
|
|
1784
|
+
function toPercent(progress) {
|
|
1785
|
+
if (progress.indeterminate) return 0;
|
|
1786
|
+
if (progress.total === void 0) return 0;
|
|
1787
|
+
if (progress.total === 0) return 100;
|
|
1788
|
+
const percent = progress.loaded / progress.total * 100;
|
|
1789
|
+
if (percent < 0) return 0;
|
|
1790
|
+
return percent > 100 ? 100 : percent;
|
|
1791
|
+
}
|
|
1792
|
+
/** Terminal frame for a transfer of `total` bytes, written on resolution. */
|
|
1793
|
+
function doneProgress(total) {
|
|
1794
|
+
return {
|
|
1795
|
+
percent: 100,
|
|
1796
|
+
loaded: total,
|
|
1797
|
+
total,
|
|
1798
|
+
indeterminate: false
|
|
1799
|
+
};
|
|
1800
|
+
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Second coalescer, on top of the client's time throttle, keyed on what
|
|
1803
|
+
* actually changed for a UI rather than on elapsed time:
|
|
1804
|
+
*
|
|
1805
|
+
* - a determinate tick commits only when the whole percent changes, capping
|
|
1806
|
+
* commits at ~101 per transfer no matter how many byte events arrive;
|
|
1807
|
+
* - a tick with no position — indeterminate, or determinate with no
|
|
1808
|
+
* denominator — has no percent to change, so it falls back to a time
|
|
1809
|
+
* budget; otherwise a byte counter with no denominator would never update;
|
|
1810
|
+
* - gaining or losing a position always commits, since the UI switches between
|
|
1811
|
+
* a spinner and a bar. Stage entry is indeterminate at 0%, so without this
|
|
1812
|
+
* the first byte event of a stage reads as "still 0%" and is dropped, and a
|
|
1813
|
+
* 50 MB upload sits on the spinner until it crosses 1%;
|
|
1814
|
+
* - a stage change always commits, because the label changed.
|
|
1815
|
+
*
|
|
1816
|
+
* Uses `Date.now()` so tests can drive it with fake timers.
|
|
1817
|
+
*/
|
|
1818
|
+
function createProgressGate(options) {
|
|
1819
|
+
const budget = options?.indeterminateCommitMs ?? 150;
|
|
1820
|
+
const now = options?.now ?? (() => Date.now());
|
|
1821
|
+
let lastStage;
|
|
1822
|
+
let lastPercent = -1;
|
|
1823
|
+
let lastIndeterminate;
|
|
1824
|
+
let lastTotalKnown;
|
|
1825
|
+
let lastCommitAt = Number.NEGATIVE_INFINITY;
|
|
1826
|
+
return (progress) => {
|
|
1827
|
+
const commit = () => {
|
|
1828
|
+
lastStage = progress.stage;
|
|
1829
|
+
lastPercent = Math.floor(toPercent(progress));
|
|
1830
|
+
lastIndeterminate = progress.indeterminate;
|
|
1831
|
+
lastTotalKnown = progress.total !== void 0;
|
|
1832
|
+
lastCommitAt = now();
|
|
1833
|
+
return true;
|
|
1834
|
+
};
|
|
1835
|
+
if (progress.stage !== lastStage) return commit();
|
|
1836
|
+
if (progress.indeterminate !== lastIndeterminate) return commit();
|
|
1837
|
+
if (progress.total !== void 0 !== lastTotalKnown) return commit();
|
|
1838
|
+
if (progress.indeterminate || progress.total === void 0) return now() - lastCommitAt >= budget ? commit() : false;
|
|
1839
|
+
return Math.floor(toPercent(progress)) !== lastPercent ? commit() : false;
|
|
1840
|
+
};
|
|
1841
|
+
}
|
|
1842
|
+
//#endregion
|
|
2993
1843
|
//#region src/hooks/use-attachments.ts
|
|
1844
|
+
/**
|
|
1845
|
+
* One client per service, shared across every component.
|
|
1846
|
+
*
|
|
1847
|
+
* A per-component `useMemo` handed each caller its own wrapper, so nothing
|
|
1848
|
+
* client-scoped could ever be shared or cached. Keyed weakly so a replaced
|
|
1849
|
+
* service is collectable.
|
|
1850
|
+
*/
|
|
1851
|
+
const clientsByService = /* @__PURE__ */ new WeakMap();
|
|
1852
|
+
function clientFor(service) {
|
|
1853
|
+
const existing = clientsByService.get(service);
|
|
1854
|
+
if (existing) return existing;
|
|
1855
|
+
const created = createAttachmentClient(service);
|
|
1856
|
+
clientsByService.set(service, created);
|
|
1857
|
+
return created;
|
|
1858
|
+
}
|
|
2994
1859
|
/** Returns an IAttachmentClient wrapping the current IAttachmentService, or undefined if none is set. */
|
|
2995
1860
|
function useAttachments() {
|
|
2996
1861
|
const service = useAttachmentService();
|
|
2997
|
-
return
|
|
2998
|
-
}
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
1862
|
+
return service ? clientFor(service) : void 0;
|
|
1863
|
+
}
|
|
1864
|
+
const DEFAULT_PREVIEW_RETRIES = 3;
|
|
1865
|
+
const DEFAULT_PREVIEW_RETRY_DELAY_MS = 3e3;
|
|
1866
|
+
const IDLE_PREVIEW = {
|
|
1867
|
+
url: void 0,
|
|
1868
|
+
header: void 0,
|
|
1869
|
+
loading: false,
|
|
1870
|
+
error: void 0,
|
|
1871
|
+
stage: "idle",
|
|
1872
|
+
progress: IDLE_PROGRESS,
|
|
1873
|
+
attempt: 0,
|
|
1874
|
+
maxAttempts: 1,
|
|
1875
|
+
lastError: void 0
|
|
1876
|
+
};
|
|
1877
|
+
/**
|
|
1878
|
+
* Document-authorized inline preview of an attachment. Downloads the bytes
|
|
1879
|
+
* through the normal authorized flow, exposes them as an object URL, and
|
|
1880
|
+
* revokes it automatically on unmount and whenever documentId/ref change —
|
|
1881
|
+
* editors never touch blobs or URL lifecycles. Failed attempts are retried
|
|
1882
|
+
* (`retries` × `retryDelayMs`) so a preview requested right after attaching
|
|
1883
|
+
* appears as soon as the server's reference index catches up. Progress resets
|
|
1884
|
+
* per attempt; nothing resumes.
|
|
1885
|
+
*/
|
|
1886
|
+
function useAttachmentPreview({ documentId, ref, retries = DEFAULT_PREVIEW_RETRIES, retryDelayMs = DEFAULT_PREVIEW_RETRY_DELAY_MS }) {
|
|
1887
|
+
const client = useAttachments();
|
|
1888
|
+
const [state, setState] = useState(IDLE_PREVIEW);
|
|
1889
|
+
useEffect(() => {
|
|
1890
|
+
if (!client || !ref) {
|
|
1891
|
+
setState(IDLE_PREVIEW);
|
|
1892
|
+
return;
|
|
1893
|
+
}
|
|
1894
|
+
const maxAttempts = retries + 1;
|
|
1895
|
+
let live = true;
|
|
1896
|
+
const controller = new AbortController();
|
|
1897
|
+
let revoke;
|
|
1898
|
+
let timer;
|
|
1899
|
+
let attempt = 0;
|
|
1900
|
+
setState({
|
|
1901
|
+
...IDLE_PREVIEW,
|
|
1902
|
+
loading: true,
|
|
1903
|
+
attempt: 1,
|
|
1904
|
+
maxAttempts
|
|
1905
|
+
});
|
|
1906
|
+
const load = () => {
|
|
1907
|
+
attempt += 1;
|
|
1908
|
+
const gate = createProgressGate();
|
|
1909
|
+
const attemptNumber = attempt;
|
|
1910
|
+
client.downloadObjectUrl({
|
|
1911
|
+
documentId,
|
|
1912
|
+
ref,
|
|
1913
|
+
signal: controller.signal
|
|
1914
|
+
}, { onProgress: (progress) => {
|
|
1915
|
+
if (!live) return;
|
|
1916
|
+
if (progress.stage === "done" || progress.stage === "error") return;
|
|
1917
|
+
if (!gate(progress)) return;
|
|
1918
|
+
setState((prev) => ({
|
|
1919
|
+
...prev,
|
|
1920
|
+
stage: progress.stage,
|
|
1921
|
+
progress: toProgressState(progress)
|
|
1922
|
+
}));
|
|
1923
|
+
} }).then((result) => {
|
|
1924
|
+
if (!live) {
|
|
1925
|
+
result.revoke();
|
|
1926
|
+
return;
|
|
1927
|
+
}
|
|
1928
|
+
revoke = result.revoke;
|
|
1929
|
+
setState((prev) => ({
|
|
1930
|
+
...prev,
|
|
1931
|
+
url: result.url,
|
|
1932
|
+
header: result.header,
|
|
1933
|
+
loading: false,
|
|
1934
|
+
error: void 0,
|
|
1935
|
+
stage: "done",
|
|
1936
|
+
progress: doneProgress(result.header.sizeBytes),
|
|
1937
|
+
attempt: attemptNumber,
|
|
1938
|
+
maxAttempts
|
|
1939
|
+
}));
|
|
1940
|
+
}).catch((err) => {
|
|
1941
|
+
if (!live) return;
|
|
1942
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
1943
|
+
if (attempt < maxAttempts) {
|
|
1944
|
+
setState((prev) => ({
|
|
1945
|
+
...prev,
|
|
1946
|
+
lastError: error,
|
|
1947
|
+
attempt: attempt + 1,
|
|
1948
|
+
progress: IDLE_PROGRESS,
|
|
1949
|
+
stage: "idle"
|
|
1950
|
+
}));
|
|
1951
|
+
timer = setTimeout(load, retryDelayMs);
|
|
1952
|
+
return;
|
|
1953
|
+
}
|
|
1954
|
+
setState((prev) => ({
|
|
1955
|
+
...prev,
|
|
1956
|
+
url: void 0,
|
|
1957
|
+
header: void 0,
|
|
1958
|
+
loading: false,
|
|
1959
|
+
error,
|
|
1960
|
+
lastError: error,
|
|
1961
|
+
stage: "error",
|
|
1962
|
+
attempt: attemptNumber,
|
|
1963
|
+
maxAttempts
|
|
1964
|
+
}));
|
|
1965
|
+
});
|
|
1966
|
+
};
|
|
1967
|
+
load();
|
|
1968
|
+
return () => {
|
|
1969
|
+
live = false;
|
|
1970
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
1971
|
+
controller.abort();
|
|
1972
|
+
revoke?.();
|
|
1973
|
+
};
|
|
1974
|
+
}, [
|
|
1975
|
+
client,
|
|
1976
|
+
documentId,
|
|
1977
|
+
ref,
|
|
1978
|
+
retries,
|
|
1979
|
+
retryDelayMs
|
|
1980
|
+
]);
|
|
1981
|
+
return state;
|
|
1982
|
+
}
|
|
1983
|
+
const IDLE_UPLOAD = {
|
|
1984
|
+
stage: "idle",
|
|
1985
|
+
progress: IDLE_PROGRESS,
|
|
1986
|
+
result: void 0,
|
|
1987
|
+
error: void 0
|
|
1988
|
+
};
|
|
1989
|
+
/**
|
|
1990
|
+
* Full attachment preprocess + upload lifecycle with byte-level progress.
|
|
1991
|
+
*
|
|
1992
|
+
* The two-call split is kept on purpose: the ref must reach the document
|
|
1993
|
+
* before the bytes are committed, so callers preprocess, dispatch the
|
|
1994
|
+
* operation, then upload. The second call routes through `client.upload`
|
|
1995
|
+
* rather than reimplementing the flow, which is what makes progress, dedup
|
|
1996
|
+
* reporting and cancellation identical to the non-React path.
|
|
1997
|
+
*/
|
|
3009
1998
|
function useAttachmentUpload() {
|
|
3010
|
-
const [
|
|
3011
|
-
const [progress, setProgress] = useState(0);
|
|
3012
|
-
const [error, setError] = useState(void 0);
|
|
1999
|
+
const [state, setState] = useState(IDLE_UPLOAD);
|
|
3013
2000
|
const client = useAttachments();
|
|
2001
|
+
const abortRef = useRef(void 0);
|
|
2002
|
+
const mountedRef = useRef(true);
|
|
2003
|
+
const runIdRef = useRef(0);
|
|
2004
|
+
useEffect(() => {
|
|
2005
|
+
mountedRef.current = true;
|
|
2006
|
+
return () => {
|
|
2007
|
+
mountedRef.current = false;
|
|
2008
|
+
};
|
|
2009
|
+
}, []);
|
|
3014
2010
|
return {
|
|
3015
2011
|
preprocess: useCallback(async (file) => {
|
|
3016
2012
|
if (!client) throw new Error("AttachmentClient not available");
|
|
3017
|
-
|
|
3018
|
-
|
|
2013
|
+
const runId = ++runIdRef.current;
|
|
2014
|
+
setState({
|
|
2015
|
+
...IDLE_UPLOAD,
|
|
2016
|
+
stage: "hashing"
|
|
2017
|
+
});
|
|
3019
2018
|
try {
|
|
3020
2019
|
return await client.preprocess(file);
|
|
3021
2020
|
} catch (err) {
|
|
3022
|
-
|
|
3023
|
-
|
|
2021
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
2022
|
+
if (mountedRef.current && runId === runIdRef.current) setState((prev) => ({
|
|
2023
|
+
...prev,
|
|
2024
|
+
stage: "error",
|
|
2025
|
+
error
|
|
2026
|
+
}));
|
|
3024
2027
|
throw err;
|
|
3025
2028
|
}
|
|
3026
2029
|
}, [client]),
|
|
3027
2030
|
upload: useCallback(async (results) => {
|
|
3028
2031
|
if (!client) throw new Error("AttachmentClient not available");
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
2032
|
+
const runId = ++runIdRef.current;
|
|
2033
|
+
const controller = new AbortController();
|
|
2034
|
+
abortRef.current = controller;
|
|
2035
|
+
const gate = createProgressGate();
|
|
2036
|
+
const isCurrent = () => mountedRef.current && runId === runIdRef.current;
|
|
2037
|
+
setState({
|
|
2038
|
+
...IDLE_UPLOAD,
|
|
2039
|
+
stage: "reserving"
|
|
2040
|
+
});
|
|
2041
|
+
let uploadResult;
|
|
3032
2042
|
try {
|
|
3033
|
-
await client.
|
|
2043
|
+
uploadResult = await client.upload({
|
|
2044
|
+
preprocessed: results,
|
|
2045
|
+
signal: controller.signal
|
|
2046
|
+
}, { onProgress: (progress) => {
|
|
2047
|
+
if (!isCurrent()) return;
|
|
2048
|
+
if (progress.stage === "done" || progress.stage === "error") return;
|
|
2049
|
+
if (!gate(progress)) return;
|
|
2050
|
+
setState((prev) => ({
|
|
2051
|
+
...prev,
|
|
2052
|
+
stage: progress.stage,
|
|
2053
|
+
progress: toProgressState(progress)
|
|
2054
|
+
}));
|
|
2055
|
+
} });
|
|
3034
2056
|
} catch (err) {
|
|
3035
|
-
|
|
3036
|
-
|
|
2057
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
2058
|
+
if (isCurrent()) setState((prev) => ({
|
|
2059
|
+
...prev,
|
|
2060
|
+
stage: "error",
|
|
2061
|
+
error
|
|
2062
|
+
}));
|
|
3037
2063
|
throw err;
|
|
3038
2064
|
}
|
|
3039
|
-
|
|
3040
|
-
|
|
2065
|
+
if (isCurrent()) setState((prev) => ({
|
|
2066
|
+
...prev,
|
|
2067
|
+
stage: "done",
|
|
2068
|
+
progress: doneProgress(results.sizeBytes),
|
|
2069
|
+
result: uploadResult,
|
|
2070
|
+
error: void 0
|
|
2071
|
+
}));
|
|
3041
2072
|
}, [client]),
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
2073
|
+
cancel: useCallback(() => {
|
|
2074
|
+
abortRef.current?.abort();
|
|
2075
|
+
}, []),
|
|
2076
|
+
reset: useCallback(() => {
|
|
2077
|
+
runIdRef.current += 1;
|
|
2078
|
+
abortRef.current?.abort();
|
|
2079
|
+
abortRef.current = void 0;
|
|
2080
|
+
setState(IDLE_UPLOAD);
|
|
2081
|
+
}, []),
|
|
2082
|
+
stage: state.stage,
|
|
2083
|
+
progress: state.progress,
|
|
2084
|
+
result: state.result,
|
|
2085
|
+
error: state.error
|
|
3045
2086
|
};
|
|
3046
2087
|
}
|
|
3047
2088
|
//#endregion
|
|
@@ -3340,12 +2381,18 @@ var RemoteClient = class {
|
|
|
3340
2381
|
}
|
|
3341
2382
|
return { operationsByScope };
|
|
3342
2383
|
}
|
|
3343
|
-
/**
|
|
2384
|
+
/**
|
|
2385
|
+
* Push actions to an existing document via MutateDocument.
|
|
2386
|
+
*
|
|
2387
|
+
* Takes the wire shape rather than an in-process `Action`: a signature is a
|
|
2388
|
+
* tuple in one and a string in the other, so the caller projects before it
|
|
2389
|
+
* gets here.
|
|
2390
|
+
*/
|
|
3344
2391
|
async pushActions(documentIdentifier, actions, branch) {
|
|
3345
2392
|
return (await this.client.MutateDocument({
|
|
3346
2393
|
documentIdentifier,
|
|
3347
2394
|
actions,
|
|
3348
|
-
|
|
2395
|
+
branch
|
|
3349
2396
|
})).mutateDocument;
|
|
3350
2397
|
}
|
|
3351
2398
|
/** Create a new document on the remote. */
|
|
@@ -3371,105 +2418,6 @@ var RemoteClient = class {
|
|
|
3371
2418
|
}
|
|
3372
2419
|
};
|
|
3373
2420
|
//#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
2421
|
//#region src/remote-controller/remote-controller.ts
|
|
3474
2422
|
/**
|
|
3475
2423
|
* A controller that wraps a PHDocumentController with remote push/pull capabilities.
|
|
@@ -3548,7 +2496,7 @@ var RemoteDocumentController = class RemoteDocumentController {
|
|
|
3548
2496
|
if (tracked.length > 0) {
|
|
3549
2497
|
const actions = await this.prepareActionsForPush(tracked);
|
|
3550
2498
|
pushedActions = actions;
|
|
3551
|
-
await this.remoteClient.pushActions(this.documentId, actions, this.options.branch);
|
|
2499
|
+
await this.remoteClient.pushActions(this.documentId, actions.map(toTransportAction), this.options.branch);
|
|
3552
2500
|
}
|
|
3553
2501
|
} catch (error) {
|
|
3554
2502
|
this.tracker.restore(tracked);
|
|
@@ -3860,6 +2808,6 @@ var BrowserLocalStorage = class extends BaseStorage {
|
|
|
3860
2808
|
}
|
|
3861
2809
|
};
|
|
3862
2810
|
//#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 };
|
|
2811
|
+
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, 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, prepareSignedActions, reactorGraphqlBatchFetchDocuments, reactorGraphqlCreateDocument, reactorGraphqlDeleteDocument, reactorGraphqlDeleteDocuments, reactorGraphqlFetchDocument, reactorGraphqlMutateDocument, readPromiseState, refreshReactorData, refreshReactorDataClient, renameDrive, renameDriveNode, resolveDocumentModelModule, 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, useCanExecute, 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
2812
|
|
|
3865
2813
|
//# sourceMappingURL=index.js.map
|