@powerhousedao/reactor-browser 6.0.0-dev.194 → 6.0.0-dev.196

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,156 +1,15 @@
1
- import { childLogger, documentModelDocumentModelModule, logger } from "document-model";
2
- import { baseLoadFromInput, baseSaveToFileHandle, buildSignedAction, createPresignedHeader, createZip, documentModelDocumentType, generateId, replayDocument, validateInitialState, validateModules, validateStateSchemaName } from "@powerhousedao/shared/document-model";
1
+ import { C as uploadOperations, S as queueOperations, _ as clearGlobal, a as setDocumentCache, b as dispatchActions, c as useDocuments, d as useGetDocuments, f as DocumentCache, g as getAnalyticsStore, h as createAnalyticsStore, i as addDocumentCacheEventHandler, l as useGetDocument, m as readPromiseState, n as useDocumentsByIds, o as useDocument, p as addPromiseState, r as useDispatch, s as useDocumentCache, t as useDocumentById, u as useGetDocumentAsync, v as getGlobal, x as queueActions, y as setGlobal } from "./document-by-id-CDLUqru5.js";
2
+ import { n as PropagationMode, t as createClient } from "./client-DMdsUVJw.js";
3
+ import { t as makePHEventFunctions } from "./make-ph-event-functions-Cr4GqOTT.js";
4
+ import { A as useLoginStatus, C as RENOWN_CHAIN_ID, D as addRenownEventHandler, E as VERIFIABLE_CREDENTIAL_EIP712_TYPE, F as setLoading, I as useLoading, M as useUser, N as addLoadingEventHandler, O as setRenown, P as loading, S as ISSUER_TYPE, T as RENOWN_URL, _ as openRenown, a as RenownAuthButton, b as CREDENTIAL_TYPES, c as ChevronDownIcon, d as RenownLogo, f as SpinnerIcon, g as logout, h as login, i as initRenownCrypto, j as useRenown, k as useDid, l as CopyIcon, m as useRenownAuth, n as useRenownInit, o as RenownUserButton, p as UserIcon, r as initConnectCrypto, s as RenownLoginButton, t as Renown, u as DisconnectIcon, v as CREDENTIAL_SCHEMA_EIP712_TYPE, w as RENOWN_NETWORK_ID, x as DOMAIN_TYPE, y as CREDENTIAL_SUBJECT_TYPE } from "./renown-CV_45Xc1.js";
5
+ import { n as useRelationalQuery, r as useRelationalDb, t as createProcessorQuery } from "./relational-jwreqDwz.js";
6
+ import { documentModelDocumentModelModule, logger } from "document-model";
7
+ import { baseLoadFromInput, baseSaveToFileHandle, createPresignedHeader, createZip, documentModelDocumentType, generateId, replayDocument, validateInitialState, validateModules, validateStateSchemaName } from "@powerhousedao/shared/document-model";
3
8
  import { addFolder as addFolder$1, copyNode, deleteNode as deleteNode$1, driveCreateDocument, generateNodesCopy, handleTargetNameCollisions, isFileNode, isFolderNode, setAvailableOffline, setSharingType, updateNode } from "@powerhousedao/shared/document-drive";
4
- import { ChannelScheme, DocumentChangeType, DocumentChangeType as DocumentChangeType$1, DocumentIntegrityService, DuplicateManifestError, DuplicateModuleError, GqlRequestChannel, GqlRequestChannel as GqlRequestChannel$1, InMemoryQueue, IntervalPollTimer, ModuleNotFoundError, REACTOR_SCHEMA, REACTOR_SCHEMA as REACTOR_SCHEMA$1, ReactorBuilder, ReactorClientBuilder, RelationalDbProcessor, SyncOperationStatus, SyncStatus, createRelationalDb, driveCollectionId, driveCollectionId as driveCollectionId$1, driveIdFromUrl, parseDriveUrl } from "@powerhousedao/reactor";
5
- import { BrowserAnalyticsStore } from "@powerhousedao/analytics-engine-browser";
6
- import { AnalyticsGranularity, AnalyticsPath, AnalyticsQueryEngine } from "@powerhousedao/analytics-engine-core";
7
- import { QueryClient, QueryClientProvider, useMutation, useQuery, useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
8
- import { Children, cloneElement, forwardRef, isValidElement, use, useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
9
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
- import { capitalCase } from "change-case";
11
- import { DateTime } from "luxon";
12
- import { GraphQLClient } from "graphql-request";
13
- import { gql } from "graphql-tag";
9
+ import { ChannelScheme, DocumentChangeType, DocumentIntegrityService, DuplicateManifestError, DuplicateModuleError, GqlRequestChannel, GqlRequestChannel as GqlRequestChannel$1, InMemoryQueue, IntervalPollTimer, ModuleNotFoundError, REACTOR_SCHEMA, REACTOR_SCHEMA as REACTOR_SCHEMA$1, ReactorBuilder, ReactorClientBuilder, RelationalDbProcessor, SyncOperationStatus, SyncStatus, driveCollectionId, driveCollectionId as driveCollectionId$1, driveIdFromUrl, parseDriveUrl } from "@powerhousedao/reactor";
10
+ import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
14
11
  import slug from "slug";
15
12
  import * as lzString from "lz-string";
16
- import { BrowserKeyStorage, RenownBuilder, RenownCryptoBuilder } from "@renown/sdk";
17
- import { Kysely } from "kysely";
18
- import { PGliteDialect } from "kysely-pglite-dialect";
19
- import deepEqual from "lodash.isequal";
20
- //#region src/actions/queue.ts
21
- async function queueActions(document, actionOrActions) {
22
- if (!document) throw new Error("No document provided");
23
- if (!actionOrActions) throw new Error("No actions provided");
24
- const actions = Array.isArray(actionOrActions) ? actionOrActions : [actionOrActions];
25
- if (actions.length === 0) throw new Error("No actions provided");
26
- const reactorClient = window.ph?.reactorClient;
27
- if (!reactorClient) throw new Error("ReactorClient not initialized");
28
- return await reactorClient.execute(document.header.id, "main", actions);
29
- }
30
- async function queueOperations(documentId, operationOrOperations) {
31
- if (!documentId) throw new Error("No documentId provided");
32
- if (!operationOrOperations) throw new Error("No operations provided");
33
- const operations = Array.isArray(operationOrOperations) ? operationOrOperations : [operationOrOperations];
34
- if (operations.length === 0) throw new Error("No operations provided");
35
- const reactorClient = window.ph?.reactorClient;
36
- if (!reactorClient) throw new Error("ReactorClient not initialized");
37
- const actions = operations.map((op) => op.action);
38
- return await reactorClient.execute(documentId, "main", actions);
39
- }
40
- async function uploadOperations(documentId, allOperations, pushOperations, options) {
41
- const operationsLimit = options?.operationsLimit || 50;
42
- const onProgress = options?.onProgress;
43
- logger.verbose(`uploadDocumentOperations(documentId:${documentId}, ops: ${Object.keys(allOperations).join(",")}, limit:${operationsLimit})`);
44
- const allOperationsArray = Object.values(allOperations).filter((ops) => ops !== void 0);
45
- const totalOperations = allOperationsArray.reduce((total, operations) => total + operations.length, 0);
46
- let uploadedOperations = 0;
47
- for (const operations of allOperationsArray) for (let i = 0; i < operations.length; i += operationsLimit) {
48
- logger.verbose(`uploadDocumentOperations:for(i:${i}, ops:${operations.length}, limit:${operationsLimit}): START`);
49
- const chunk = operations.slice(i, i + operationsLimit);
50
- const operation = chunk.at(-1);
51
- if (!operation) break;
52
- const scope = operation.action.scope;
53
- await pushOperations(documentId, chunk);
54
- uploadedOperations += chunk.length;
55
- if (onProgress) onProgress({
56
- stage: "uploading",
57
- progress: Math.round(uploadedOperations / totalOperations * 100),
58
- totalOperations,
59
- uploadedOperations
60
- });
61
- logger.verbose(`uploadDocumentOperations:for:waitForUpdate(${documentId}:${scope} rev ${operation.index}): NEXT`);
62
- }
63
- logger.verbose(`uploadDocumentOperations:for:waitForUpdate(${documentId}): END`);
64
- }
65
- //#endregion
66
- //#region src/actions/sign.ts
67
- async function signAction(action, document) {
68
- const reactor = window.ph?.reactorClient;
69
- if (!reactor) return action;
70
- const reducer = (await reactor.getDocumentModelModule(document.header.documentType)).reducer;
71
- const renown = window.ph?.renown;
72
- if (!renown?.user) return action;
73
- if (!action.context?.signer) return action;
74
- const actionSigner = action.context.signer;
75
- return await buildSignedAction(action, reducer, document, actionSigner, renown.crypto.sign);
76
- }
77
- function addActionContext(action) {
78
- const renown = window.ph?.renown;
79
- if (!renown?.user) return action;
80
- return {
81
- context: { signer: {
82
- app: {
83
- name: "Connect",
84
- key: renown.did
85
- },
86
- user: {
87
- address: renown.user.address,
88
- networkId: renown.user.networkId,
89
- chainId: renown.user.chainId
90
- },
91
- signatures: []
92
- } },
93
- ...action
94
- };
95
- }
96
- async function makeSignedActionWithContext(action, document) {
97
- if (!action) {
98
- logger.error("No action found");
99
- return;
100
- }
101
- if (!document) {
102
- logger.error("No document found");
103
- return;
104
- }
105
- return addActionContext(await signAction(action, document));
106
- }
107
- async function makeSignedActionsWithContext(actionOrActions, document) {
108
- if (!actionOrActions) {
109
- logger.error("No actions found");
110
- return;
111
- }
112
- const actions = Array.isArray(actionOrActions) ? actionOrActions : [actionOrActions];
113
- return (await Promise.all(actions.map((action) => makeSignedActionWithContext(action, document)))).filter((a) => a !== void 0);
114
- }
115
- //#endregion
116
- //#region src/actions/dispatch.ts
117
- async function getDocument(documentId) {
118
- try {
119
- return await window.ph?.reactorClient?.get(documentId);
120
- } catch (error) {
121
- logger.debug(`Failed to get document with id ${documentId}:`, error);
122
- return;
123
- }
124
- }
125
- function getActionErrors(result, actions) {
126
- return actions.reduce((errors, a) => {
127
- const scopeOperations = result.operations[a.scope];
128
- if (!scopeOperations) return errors;
129
- const op = scopeOperations.findLast((op) => op.action.id === a.id);
130
- if (op?.error) errors.push(new Error(op.error));
131
- return errors;
132
- }, new Array());
133
- }
134
- async function dispatchActions(actionOrActions, documentOrDocumentId, onErrors, onSuccess) {
135
- const document = typeof documentOrDocumentId === "string" ? await getDocument(documentOrDocumentId) : documentOrDocumentId;
136
- if (!document) {
137
- logger.error(`Document with id ${JSON.stringify(documentOrDocumentId)} not found`);
138
- return;
139
- }
140
- const signedActionsWithContext = await makeSignedActionsWithContext(actionOrActions, document);
141
- if (!signedActionsWithContext) {
142
- logger.error("No signed actions with context found");
143
- return;
144
- }
145
- const result = await queueActions(document, signedActionsWithContext);
146
- if (onErrors && result) {
147
- const errors = getActionErrors(result, signedActionsWithContext);
148
- if (errors.length) onErrors(errors);
149
- }
150
- if (onSuccess && result) onSuccess(result);
151
- return result;
152
- }
153
- //#endregion
154
13
  //#region src/errors.ts
155
14
  var UnsupportedDocumentTypeError = class extends Error {
156
15
  constructor(documentType) {
@@ -256,8 +115,8 @@ function getDocumentTypeIcon(document) {
256
115
  default: return;
257
116
  }
258
117
  }
259
- function downloadFile(document, fileName) {
260
- createZip(document).generateAsync({ type: "blob" }).then((blob) => {
118
+ async function downloadFile(document, fileName) {
119
+ (await createZip(document)).generateAsync({ type: "blob" }).then((blob) => {
261
120
  const link = window.document.createElement("a");
262
121
  link.style.display = "none";
263
122
  link.href = URL.createObjectURL(blob);
@@ -327,7 +186,7 @@ async function exportFile(document, suggestedName) {
327
186
  const extension = await getDocumentExtension(documentWithOps);
328
187
  const baseName = suggestedName || documentWithOps.header.name || "Untitled";
329
188
  const name = extension ? `${baseName}.${extension}.phd` : `${baseName}.phd`;
330
- if (!window.showSaveFilePicker) return downloadFile(documentWithOps, name);
189
+ if (!window.showSaveFilePicker) return await downloadFile(documentWithOps, name);
331
190
  try {
332
191
  const fileHandle = await window.showSaveFilePicker({ suggestedName: name });
333
192
  await baseSaveToFileHandle(documentWithOps, fileHandle);
@@ -684,686 +543,6 @@ async function setDriveSharingType(driveId, sharingType) {
684
543
  return await reactorClient.execute(driveId, "main", [setSharingType({ type: sharingType })]);
685
544
  }
686
545
  //#endregion
687
- //#region src/global/core.ts
688
- function getGlobal(namespace) {
689
- if (typeof window === "undefined") return void 0;
690
- return window.powerhouse?.[namespace];
691
- }
692
- function setGlobal(namespace, value) {
693
- if (typeof window === "undefined") return;
694
- window.powerhouse = window.powerhouse || {};
695
- window.powerhouse[namespace] = value;
696
- }
697
- function clearGlobal(namespace) {
698
- if (typeof window === "undefined") return;
699
- if (window.powerhouse?.[namespace]) {
700
- delete window.powerhouse[namespace];
701
- if (Object.keys(window.powerhouse).length === 0) delete window.powerhouse;
702
- }
703
- }
704
- //#endregion
705
- //#region src/analytics/context.tsx
706
- childLogger([
707
- "reactor-browser",
708
- "analytics",
709
- "provider"
710
- ]);
711
- const defaultQueryClient = new QueryClient();
712
- const analyticsOptionsKey = ["analytics", "options"];
713
- const analyticsStoreKey = ["analytics", "store"];
714
- const analyticsEngineKey = ["analytics", "store"];
715
- async function createAnalyticsStore(options) {
716
- const store = new BrowserAnalyticsStore(options);
717
- await store.init();
718
- return {
719
- store,
720
- engine: new AnalyticsQueryEngine(store),
721
- options
722
- };
723
- }
724
- async function getAnalyticsStore() {
725
- return (await getGlobal("analytics"))?.store ?? null;
726
- }
727
- function useAnalyticsStoreOptions() {
728
- return useQuery({ queryKey: analyticsOptionsKey }).data;
729
- }
730
- function useCreateAnalyticsStore(options) {
731
- const queryClient = useQueryClient();
732
- useEffect(() => {
733
- queryClient.setQueryDefaults(analyticsOptionsKey, {
734
- queryFn: () => options,
735
- staleTime: Infinity,
736
- gcTime: Infinity
737
- });
738
- }, [queryClient, options]);
739
- return useMutation({ mutationFn: async () => {
740
- const store = getAnalyticsStore();
741
- queryClient.setQueryDefaults(analyticsStoreKey, {
742
- queryFn: () => store,
743
- staleTime: Infinity,
744
- gcTime: Infinity
745
- });
746
- return store;
747
- } });
748
- }
749
- function useAnalyticsStoreQuery(options) {
750
- return useSuspenseQuery({
751
- queryKey: [analyticsStoreKey, options],
752
- queryFn: () => getAnalyticsStore(),
753
- retry: true
754
- });
755
- }
756
- function useAnalyticsStore(options) {
757
- return useAnalyticsStoreQuery(options).data;
758
- }
759
- function useAnalyticsStoreAsync(options) {
760
- return useQuery({
761
- queryKey: [analyticsStoreKey, options],
762
- queryFn: () => getAnalyticsStore(),
763
- retry: true,
764
- throwOnError: false
765
- });
766
- }
767
- function CreateAnalyticsStore() {
768
- const { mutate } = useCreateAnalyticsStore();
769
- useEffect(() => {
770
- mutate();
771
- }, []);
772
- return null;
773
- }
774
- function AnalyticsProvider({ children, queryClient = defaultQueryClient, ...props }) {
775
- return /* @__PURE__ */ jsxs(QueryClientProvider, {
776
- client: queryClient,
777
- children: [/* @__PURE__ */ jsx(CreateAnalyticsStore, {}), children]
778
- });
779
- }
780
- function useAnalyticsEngine() {
781
- return useSuspenseQuery({
782
- queryKey: analyticsEngineKey,
783
- queryFn: async () => {
784
- const globalAnalytics = getGlobal("analytics");
785
- if (!globalAnalytics) throw new Error("No analytics store available");
786
- return (await globalAnalytics).engine;
787
- },
788
- retry: false
789
- }).data;
790
- }
791
- function useAnalyticsEngineAsync() {
792
- return useQuery({
793
- queryKey: analyticsEngineKey,
794
- queryFn: async () => {
795
- const globalAnalytics = getGlobal("analytics");
796
- if (!globalAnalytics) throw new Error("No analytics store available");
797
- return (await globalAnalytics).engine;
798
- },
799
- retry: false
800
- });
801
- }
802
- //#endregion
803
- //#region src/analytics/hooks/analytics-query.ts
804
- function useAnalyticsQueryWrapper(options) {
805
- const { queryFn, ...queryOptions } = options;
806
- const { data: store } = useAnalyticsStoreAsync();
807
- const { data: engine } = useAnalyticsEngineAsync();
808
- const enabled = "enabled" in queryOptions ? queryOptions.enabled : !!store && !!engine;
809
- return useQuery({
810
- ...queryOptions,
811
- enabled,
812
- queryFn: async () => {
813
- if (!store || !engine) throw new Error("No analytics store available. Use within an AnalyticsProvider.");
814
- return await queryFn({
815
- store,
816
- engine
817
- });
818
- }
819
- });
820
- }
821
- function useAnalyticsMutationWrapper(options) {
822
- const { mutationFn, ...mutationOptions } = options;
823
- useAnalyticsStoreOptions();
824
- return useMutation({
825
- ...mutationOptions,
826
- mutationFn: async (value) => {
827
- let store = null;
828
- try {
829
- store = await getAnalyticsStore();
830
- } catch (e) {
831
- console.error(e);
832
- }
833
- if (!store) throw new Error("No analytics store available. Use within an AnalyticsProvider.");
834
- return await mutationFn(value, { store });
835
- }
836
- });
837
- }
838
- const DEBOUNCE_INTERVAL = 200;
839
- function useAnalyticsQuery(query, options) {
840
- const { data: store } = useAnalyticsStoreAsync();
841
- const queryClient = useQueryClient();
842
- const sources = options?.sources ?? [];
843
- const result = useAnalyticsQueryWrapper({
844
- queryKey: [
845
- "analytics",
846
- "query",
847
- query
848
- ],
849
- queryFn: ({ engine }) => engine.execute(query),
850
- ...options
851
- });
852
- useEffect(() => {
853
- if (!sources.length || !store) return;
854
- const subscriptions = new Array();
855
- let invalidateTimeout = null;
856
- const debouncedInvalidate = () => {
857
- if (invalidateTimeout) clearTimeout(invalidateTimeout);
858
- invalidateTimeout = setTimeout(() => {
859
- queryClient.invalidateQueries({ queryKey: [
860
- "analytics",
861
- "query",
862
- query
863
- ] }).catch((e) => {
864
- console.error(e);
865
- });
866
- }, DEBOUNCE_INTERVAL);
867
- };
868
- sources.forEach((path) => {
869
- const unsub = store.subscribeToSource(path, debouncedInvalidate);
870
- subscriptions.push(unsub);
871
- });
872
- return () => {
873
- subscriptions.forEach((unsub) => unsub());
874
- };
875
- }, [
876
- query,
877
- store,
878
- sources
879
- ]);
880
- return result;
881
- }
882
- function useAnalyticsSeries(query, options) {
883
- return useAnalyticsQueryWrapper({
884
- queryKey: [
885
- "analytics",
886
- "series",
887
- query
888
- ],
889
- queryFn: ({ store }) => store.getMatchingSeries(query),
890
- ...options
891
- });
892
- }
893
- function useAddSeriesValue(options) {
894
- return useAnalyticsMutationWrapper({
895
- mutationKey: ["analytics", "addSeries"],
896
- mutationFn: async (value, { store }) => {
897
- return await store.addSeriesValue(value);
898
- },
899
- ...options
900
- });
901
- }
902
- function useClearSeriesBySource(options) {
903
- return useAnalyticsMutationWrapper({
904
- mutationKey: ["analytics", "clearSeries"],
905
- mutationFn: async ({ source, cleanUpDimensions }, { store }) => {
906
- return store.clearSeriesBySource(source, cleanUpDimensions);
907
- },
908
- ...options
909
- });
910
- }
911
- function useClearEmptyAnalyticsDimensions(options) {
912
- return useAnalyticsMutationWrapper({
913
- mutationKey: ["analytics", "clearEmptyDimensions"],
914
- mutationFn: async (_, { store }) => {
915
- return store.clearEmptyAnalyticsDimensions();
916
- },
917
- ...options
918
- });
919
- }
920
- function useAddSeriesValues(options) {
921
- return useAnalyticsMutationWrapper({
922
- mutationKey: ["analytics", "addSeriesValues"],
923
- mutationFn: async (values, { store }) => {
924
- return store.addSeriesValues(values);
925
- },
926
- ...options
927
- });
928
- }
929
- function useGetDimensions(options) {
930
- return useAnalyticsQueryWrapper({
931
- queryKey: ["analytics", "dimensions"],
932
- queryFn: ({ store }) => store.getDimensions(),
933
- ...options
934
- });
935
- }
936
- function useMatchingSeries(query, options) {
937
- return useAnalyticsQueryWrapper({
938
- queryKey: [
939
- "analytics",
940
- "matchingSeries",
941
- query
942
- ],
943
- queryFn: ({ store }) => store.getMatchingSeries(query),
944
- ...options
945
- });
946
- }
947
- function useQuerySources(query, options) {
948
- const { data: matchingSeries } = useMatchingSeries(query);
949
- return useQuery({
950
- queryKey: [
951
- "analytics",
952
- "sources",
953
- query
954
- ],
955
- queryFn: () => {
956
- if (!matchingSeries?.length) return [];
957
- return [...new Set(matchingSeries.map((s) => s.source.toString()))].map((source) => AnalyticsPath.fromString(source));
958
- },
959
- enabled: !!matchingSeries,
960
- ...options
961
- });
962
- }
963
- //#endregion
964
- //#region src/hooks/dispatch.ts
965
- function useDispatch(document) {
966
- /**
967
- * Dispatches actions to the document.
968
- * @param actionOrActions - The action or actions to dispatch.
969
- * @param onErrors - Callback invoked with any errors that occurred during action execution.
970
- */
971
- function dispatch(actionOrActions, onErrors, onSuccess) {
972
- dispatchActions(actionOrActions, document, onErrors, onSuccess).catch(logger.error);
973
- }
974
- return [document, dispatch];
975
- }
976
- //#endregion
977
- //#region src/document-cache.ts
978
- function addPromiseState(promise) {
979
- if ("status" in promise) return promise;
980
- const promiseWithState = promise;
981
- promiseWithState.status = "pending";
982
- promiseWithState.then((value) => {
983
- promiseWithState.status = "fulfilled";
984
- promiseWithState.value = value;
985
- }, (reason) => {
986
- promiseWithState.status = "rejected";
987
- promiseWithState.reason = reason;
988
- throw reason;
989
- });
990
- return promiseWithState;
991
- }
992
- function readPromiseState(promise) {
993
- return "status" in promise ? promise : { status: "pending" };
994
- }
995
- /**
996
- * Document cache implementation that uses the new ReactorClient API.
997
- *
998
- * This cache subscribes to document change events via IReactorClient.subscribe()
999
- * and automatically updates the cache when documents are created, updated, or deleted.
1000
- */
1001
- var DocumentCache = class {
1002
- documents = /* @__PURE__ */ new Map();
1003
- batchPromises = /* @__PURE__ */ new Map();
1004
- listeners = /* @__PURE__ */ new Map();
1005
- unsubscribe = null;
1006
- constructor(client) {
1007
- this.client = client;
1008
- this.unsubscribe = client.subscribe({}, (event) => {
1009
- this.handleDocumentChange(event);
1010
- });
1011
- }
1012
- handleDocumentChange(event) {
1013
- if (event.type === DocumentChangeType$1.Deleted) {
1014
- const documentId = event.context?.childId;
1015
- if (documentId) this.handleDocumentDeleted(documentId);
1016
- } else if (event.type === DocumentChangeType$1.Updated) for (const doc of event.documents) this.handleDocumentUpdated(doc.header.id).catch(console.warn);
1017
- }
1018
- handleDocumentDeleted(documentId) {
1019
- const listeners = this.listeners.get(documentId);
1020
- this.documents.delete(documentId);
1021
- this.invalidateBatchesContaining(documentId);
1022
- if (listeners) listeners.forEach((listener) => listener());
1023
- this.listeners.delete(documentId);
1024
- }
1025
- async handleDocumentUpdated(documentId) {
1026
- if (this.documents.has(documentId)) {
1027
- await this.get(documentId, true);
1028
- const listeners = this.listeners.get(documentId);
1029
- if (listeners) listeners.forEach((listener) => listener());
1030
- }
1031
- }
1032
- invalidateBatchesContaining(documentId) {
1033
- for (const key of this.batchPromises.keys()) if (key.split(",").includes(documentId)) this.batchPromises.delete(key);
1034
- }
1035
- get(id, refetch) {
1036
- const currentData = this.documents.get(id);
1037
- if (currentData) {
1038
- if (currentData.status === "pending") return currentData;
1039
- if (!refetch) return currentData;
1040
- }
1041
- const documentPromise = this.client.get(id);
1042
- this.documents.set(id, addPromiseState(documentPromise));
1043
- return documentPromise;
1044
- }
1045
- getBatch(ids) {
1046
- const key = ids.join(",");
1047
- const cached = this.batchPromises.get(key);
1048
- const hasDeletedDocuments = ids.some((id) => !this.documents.has(id));
1049
- const currentPromises = ids.map((id) => this.get(id));
1050
- if (hasDeletedDocuments) {
1051
- const batchPromise = Promise.all(currentPromises);
1052
- this.batchPromises.set(key, {
1053
- promises: currentPromises,
1054
- promise: batchPromise
1055
- });
1056
- return batchPromise;
1057
- }
1058
- if (cached) {
1059
- if (currentPromises.every((p, i) => p === cached.promises[i])) return cached.promise;
1060
- }
1061
- const states = currentPromises.map((p) => readPromiseState(p));
1062
- if (states.every((s) => s.status === "fulfilled")) {
1063
- const values = states.map((s) => s.value);
1064
- const batchPromise = Promise.resolve(values);
1065
- batchPromise.status = "fulfilled";
1066
- batchPromise.value = values;
1067
- this.batchPromises.set(key, {
1068
- promises: currentPromises,
1069
- promise: batchPromise
1070
- });
1071
- return batchPromise;
1072
- }
1073
- if (cached) return cached.promise;
1074
- const batchPromise = Promise.all(currentPromises);
1075
- this.batchPromises.set(key, {
1076
- promises: currentPromises,
1077
- promise: batchPromise
1078
- });
1079
- return batchPromise;
1080
- }
1081
- subscribe(id, callback) {
1082
- const ids = Array.isArray(id) ? id : [id];
1083
- for (const docId of ids) {
1084
- const listeners = this.listeners.get(docId) ?? [];
1085
- this.listeners.set(docId, [...listeners, callback]);
1086
- }
1087
- return () => {
1088
- for (const docId of ids) {
1089
- const listeners = this.listeners.get(docId) ?? [];
1090
- this.listeners.set(docId, listeners.filter((listener) => listener !== callback));
1091
- }
1092
- };
1093
- }
1094
- /**
1095
- * Disposes of the cache and unsubscribes from document change events.
1096
- */
1097
- dispose() {
1098
- if (this.unsubscribe) {
1099
- this.unsubscribe();
1100
- this.unsubscribe = null;
1101
- }
1102
- }
1103
- };
1104
- //#endregion
1105
- //#region src/hooks/make-ph-event-functions.ts
1106
- const isServer = typeof window === "undefined";
1107
- function makePHEventFunctions(key) {
1108
- const setEventName = `ph:set${capitalCase(key)}`;
1109
- const updateEventName = `ph:${key}Updated`;
1110
- function setValue(value) {
1111
- if (isServer) return;
1112
- const event = new CustomEvent(setEventName, { detail: { [key]: value } });
1113
- window.dispatchEvent(event);
1114
- }
1115
- function dispatchUpdatedEvent() {
1116
- if (isServer) return;
1117
- const event = new CustomEvent(updateEventName);
1118
- window.dispatchEvent(event);
1119
- }
1120
- function handleSetValueEvent(event) {
1121
- if (isServer) return;
1122
- const value = event.detail[key];
1123
- if (!window.ph) window.ph = {};
1124
- window.ph[key] = value;
1125
- dispatchUpdatedEvent();
1126
- }
1127
- function addEventHandler() {
1128
- if (isServer) return;
1129
- window.addEventListener(setEventName, handleSetValueEvent);
1130
- }
1131
- function subscribeToValue(onStoreChange) {
1132
- if (isServer) return () => {};
1133
- window.addEventListener(updateEventName, onStoreChange);
1134
- return () => {
1135
- window.removeEventListener(updateEventName, onStoreChange);
1136
- };
1137
- }
1138
- function getSnapshot() {
1139
- if (isServer) return;
1140
- if (!window.ph) {
1141
- console.warn(`ph global store is not initialized. Did you call set${capitalCase(key)}?`);
1142
- return;
1143
- }
1144
- return window.ph[key];
1145
- }
1146
- function getServerSnapshot() {}
1147
- function useValue() {
1148
- return useSyncExternalStore(subscribeToValue, getSnapshot, getServerSnapshot);
1149
- }
1150
- return {
1151
- useValue,
1152
- setValue,
1153
- addEventHandler
1154
- };
1155
- }
1156
- //#endregion
1157
- //#region src/hooks/document-cache.ts
1158
- const documentEventFunctions = makePHEventFunctions("documentCache");
1159
- /** Returns all documents in the reactor. */
1160
- const useDocumentCache = documentEventFunctions.useValue;
1161
- /** Sets all of the documents in the reactor. */
1162
- const setDocumentCache = documentEventFunctions.setValue;
1163
- /** Adds an event handler for all of the documents in the reactor. */
1164
- const addDocumentCacheEventHandler = documentEventFunctions.addEventHandler;
1165
- /**
1166
- * Reads the state of a document promise and converts it to a query state object.
1167
- * @param promise - The document promise to read
1168
- * @returns An object containing the status, data, error, and isPending flag
1169
- */
1170
- function getDocumentQueryState(promise) {
1171
- const state = readPromiseState(promise);
1172
- switch (state.status) {
1173
- case "pending": return {
1174
- status: "pending",
1175
- isPending: true,
1176
- error: void 0,
1177
- data: void 0
1178
- };
1179
- case "fulfilled": return {
1180
- status: "success",
1181
- isPending: false,
1182
- error: void 0,
1183
- data: state.value
1184
- };
1185
- case "rejected": return {
1186
- status: "error",
1187
- isPending: false,
1188
- error: state.reason,
1189
- data: void 0
1190
- };
1191
- }
1192
- }
1193
- /**
1194
- * Retrieves a document from the reactor and subscribes to changes using React Suspense.
1195
- * This hook will suspend rendering while the document is loading.
1196
- * @param id - The document ID to retrieve, or null/undefined to skip retrieval
1197
- * @returns The document if found, or undefined if id is null/undefined
1198
- */
1199
- function useDocument(id) {
1200
- const documentCache = useDocumentCache();
1201
- const document = useSyncExternalStore((cb) => id && documentCache ? documentCache.subscribe(id, cb) : () => {}, () => id ? documentCache?.get(id) : void 0);
1202
- return document ? use(document) : void 0;
1203
- }
1204
- /**
1205
- * Retrieves multiple documents from the reactor using React Suspense.
1206
- * This hook will suspend rendering while any of the documents are loading.
1207
- *
1208
- * Uses getBatch from the document cache which handles promise caching internally,
1209
- * ensuring stable references for useSyncExternalStore.
1210
- *
1211
- * @param ids - Array of document IDs to retrieve, or null/undefined to skip retrieval
1212
- * @returns An array of documents if found, or empty array if ids is null/undefined
1213
- */
1214
- function useDocuments(ids) {
1215
- const documentCache = useDocumentCache();
1216
- const documents = useSyncExternalStore((cb) => ids?.length && documentCache ? documentCache.subscribe(ids, cb) : () => {}, () => ids?.length && documentCache ? documentCache.getBatch(ids) : void 0);
1217
- return documents ? use(documents) : [];
1218
- }
1219
- /**
1220
- * Returns a function to retrieve a document from the cache.
1221
- * The returned function fetches and returns a document by ID.
1222
- * @returns A function that takes a document ID and returns a Promise of the document
1223
- */
1224
- function useGetDocument() {
1225
- const documentCache = useDocumentCache();
1226
- return useCallback((id) => {
1227
- if (!documentCache) return Promise.reject(/* @__PURE__ */ new Error("Document cache not initialized"));
1228
- return documentCache.get(id);
1229
- }, [documentCache]);
1230
- }
1231
- /**
1232
- * Returns a function to retrieve multiple documents from the cache.
1233
- * The returned function fetches and returns documents by their IDs.
1234
- * @returns A function that takes an array of document IDs and returns a Promise of the documents
1235
- */
1236
- function useGetDocuments() {
1237
- const documentCache = useDocumentCache();
1238
- return useCallback((ids) => {
1239
- if (!documentCache) return Promise.reject(/* @__PURE__ */ new Error("Document cache not initialized"));
1240
- return documentCache.getBatch(ids);
1241
- }, [documentCache]);
1242
- }
1243
- /**
1244
- * Retrieves a document from the reactor without suspending rendering.
1245
- * Returns the current state of the document loading operation.
1246
- * @param id - The document ID to retrieve, or null/undefined to skip retrieval
1247
- * @returns An object containing:
1248
- * - status: "initial" | "pending" | "success" | "error"
1249
- * - data: The document if successfully loaded
1250
- * - isPending: Boolean indicating if the document is currently loading
1251
- * - error: Any error that occurred during loading
1252
- * - reload: Function to force reload the document from cache
1253
- */
1254
- function useGetDocumentAsync(id) {
1255
- const documentCache = useDocumentCache();
1256
- if (!id || !documentCache) return {
1257
- status: "initial",
1258
- data: void 0,
1259
- isPending: false,
1260
- error: void 0,
1261
- reload: void 0
1262
- };
1263
- return {
1264
- ...getDocumentQueryState(documentCache.get(id)),
1265
- reload: () => documentCache.get(id, true)
1266
- };
1267
- }
1268
- //#endregion
1269
- //#region src/hooks/document-by-id.ts
1270
- /** Returns a document by id. */
1271
- function useDocumentById(id) {
1272
- const document = useDocument(id);
1273
- const [, dispatch] = useDispatch(document);
1274
- return [document, dispatch];
1275
- }
1276
- /** Returns documents by ids. */
1277
- function useDocumentsByIds(ids) {
1278
- return useDocuments(ids);
1279
- }
1280
- //#endregion
1281
- //#region src/analytics/hooks/timeline-items.ts
1282
- const getBarSize = (value) => {
1283
- if (value <= 0) return 0;
1284
- if (value > 0 && value <= 50) return 1;
1285
- if (value > 50 && value <= 100) return 2;
1286
- if (value > 100 && value <= 250) return 3;
1287
- return 4;
1288
- };
1289
- function addItemsDividers(items) {
1290
- if (!items.length) return [];
1291
- const result = [];
1292
- items.forEach((item, index) => {
1293
- result.push(item);
1294
- if (index < items.length - 1) {
1295
- const currentDate = new Date(item.startDate);
1296
- const nextDate = new Date(items[index + 1].startDate);
1297
- const currentHour = currentDate.getHours();
1298
- const nextHour = nextDate.getHours();
1299
- const currentDay = currentDate.toDateString();
1300
- const nextDay = nextDate.toDateString();
1301
- if (currentDay !== nextDay || currentDay === nextDay && Math.abs(nextHour - currentHour) > 1) result.push({
1302
- id: `divider-${item.id}-${items[index + 1].id}`,
1303
- type: "divider",
1304
- revision: 0
1305
- });
1306
- }
1307
- });
1308
- return result;
1309
- }
1310
- function metricsToItems(metrics) {
1311
- if (!metrics) return [];
1312
- return addItemsDividers(metrics.sort((a, b) => {
1313
- const aDate = new Date(a.start);
1314
- const bDate = new Date(b.start);
1315
- return aDate.getTime() - bDate.getTime();
1316
- }).filter((result) => {
1317
- return result.rows.every((row) => row.value > 0);
1318
- }).map((result) => {
1319
- const { additions, deletions } = result.rows.reduce((acc, row) => {
1320
- if (row.dimensions.changes.path === "ph/diff/changes/add") acc.additions += row.value;
1321
- else if (row.dimensions.changes.path === "ph/diff/changes/remove") acc.deletions += row.value;
1322
- return acc;
1323
- }, {
1324
- additions: 0,
1325
- deletions: 0
1326
- });
1327
- const startDate = new Date(result.start);
1328
- return {
1329
- id: startDate.toISOString(),
1330
- type: "bar",
1331
- addSize: getBarSize(additions),
1332
- delSize: getBarSize(deletions),
1333
- additions,
1334
- deletions,
1335
- timestampUtcMs: startDate.toISOString(),
1336
- startDate,
1337
- endDate: new Date(result.end),
1338
- revision: 0
1339
- };
1340
- }));
1341
- }
1342
- const useTimelineItems = (documentId, startTimestamp, driveId) => {
1343
- return useAnalyticsQuery({
1344
- start: startTimestamp ? DateTime.fromISO(startTimestamp) : DateTime.now().startOf("day"),
1345
- end: DateTime.now().endOf("day"),
1346
- granularity: AnalyticsGranularity.Hourly,
1347
- metrics: ["Count"],
1348
- select: {
1349
- changes: [AnalyticsPath.fromString(`ph/diff/changes`)],
1350
- document: [AnalyticsPath.fromString(`ph/diff/document/${documentId}`)]
1351
- },
1352
- lod: { changes: 4 }
1353
- }, {
1354
- sources: [AnalyticsPath.fromString(`ph/diff/${driveId}/${documentId}`)],
1355
- select: metricsToItems
1356
- });
1357
- };
1358
- //#endregion
1359
- //#region src/analytics/hooks/document-timeline.ts
1360
- function useDocumentTimeline(documentId) {
1361
- const [document] = useDocumentById(documentId);
1362
- const id = document?.header.id;
1363
- const createdAt = document?.header.createdAtUtcIso;
1364
- return useTimelineItems(id, createdAt).data || [];
1365
- }
1366
- //#endregion
1367
546
  //#region src/constants.ts
1368
547
  const DEFAULT_DRIVE_EDITOR_ID = "powerhouse/generic-drive-explorer";
1369
548
  const COMMON_PACKAGE_ID = "powerhouse/common";
@@ -1372,1080 +551,6 @@ const COMMON_PACKAGE_ID = "powerhouse/common";
1372
551
  const baseDocumentModelsMap = { DocumentModel: documentModelDocumentModelModule };
1373
552
  const baseDocumentModels = Object.values(baseDocumentModelsMap);
1374
553
  //#endregion
1375
- //#region src/graphql/gen/schema.ts
1376
- let PropagationMode = /* @__PURE__ */ function(PropagationMode) {
1377
- PropagationMode["Cascade"] = "CASCADE";
1378
- PropagationMode["Orphan"] = "ORPHAN";
1379
- return PropagationMode;
1380
- }({});
1381
- const PhDocumentFieldsFragmentDoc = gql`
1382
- fragment PHDocumentFields on PHDocument {
1383
- id
1384
- slug
1385
- name
1386
- documentType
1387
- state
1388
- revisionsList {
1389
- scope
1390
- revision
1391
- }
1392
- createdAtUtcIso
1393
- lastModifiedAtUtcIso
1394
- }
1395
- `;
1396
- const GetDocumentModelsDocument = gql`
1397
- query GetDocumentModels($namespace: String, $paging: PagingInput) {
1398
- documentModels(namespace: $namespace, paging: $paging) {
1399
- items {
1400
- id
1401
- name
1402
- namespace
1403
- version
1404
- specification
1405
- }
1406
- totalCount
1407
- hasNextPage
1408
- hasPreviousPage
1409
- cursor
1410
- }
1411
- }
1412
- `;
1413
- const GetDocumentDocument = gql`
1414
- query GetDocument($identifier: String!, $view: ViewFilterInput) {
1415
- document(identifier: $identifier, view: $view) {
1416
- document {
1417
- ...PHDocumentFields
1418
- }
1419
- childIds
1420
- }
1421
- }
1422
- ${PhDocumentFieldsFragmentDoc}
1423
- `;
1424
- const GetDocumentWithOperationsDocument = gql`
1425
- query GetDocumentWithOperations(
1426
- $identifier: String!
1427
- $view: ViewFilterInput
1428
- $operationsFilter: DocumentOperationsFilterInput
1429
- $operationsPaging: PagingInput
1430
- ) {
1431
- document(identifier: $identifier, view: $view) {
1432
- document {
1433
- ...PHDocumentFields
1434
- operations(filter: $operationsFilter, paging: $operationsPaging) {
1435
- items {
1436
- index
1437
- timestampUtcMs
1438
- hash
1439
- skip
1440
- error
1441
- id
1442
- action {
1443
- id
1444
- type
1445
- timestampUtcMs
1446
- input
1447
- scope
1448
- attachments {
1449
- data
1450
- mimeType
1451
- hash
1452
- extension
1453
- fileName
1454
- }
1455
- context {
1456
- signer {
1457
- user {
1458
- address
1459
- networkId
1460
- chainId
1461
- }
1462
- app {
1463
- name
1464
- key
1465
- }
1466
- signatures
1467
- }
1468
- }
1469
- }
1470
- }
1471
- totalCount
1472
- hasNextPage
1473
- hasPreviousPage
1474
- cursor
1475
- }
1476
- }
1477
- childIds
1478
- }
1479
- }
1480
- ${PhDocumentFieldsFragmentDoc}
1481
- `;
1482
- const GetDocumentChildrenDocument = gql`
1483
- query GetDocumentChildren(
1484
- $parentIdentifier: String!
1485
- $view: ViewFilterInput
1486
- $paging: PagingInput
1487
- ) {
1488
- documentChildren(
1489
- parentIdentifier: $parentIdentifier
1490
- view: $view
1491
- paging: $paging
1492
- ) {
1493
- items {
1494
- ...PHDocumentFields
1495
- }
1496
- totalCount
1497
- hasNextPage
1498
- hasPreviousPage
1499
- cursor
1500
- }
1501
- }
1502
- ${PhDocumentFieldsFragmentDoc}
1503
- `;
1504
- const GetDocumentParentsDocument = gql`
1505
- query GetDocumentParents(
1506
- $childIdentifier: String!
1507
- $view: ViewFilterInput
1508
- $paging: PagingInput
1509
- ) {
1510
- documentParents(
1511
- childIdentifier: $childIdentifier
1512
- view: $view
1513
- paging: $paging
1514
- ) {
1515
- items {
1516
- ...PHDocumentFields
1517
- }
1518
- totalCount
1519
- hasNextPage
1520
- hasPreviousPage
1521
- cursor
1522
- }
1523
- }
1524
- ${PhDocumentFieldsFragmentDoc}
1525
- `;
1526
- const FindDocumentsDocument = gql`
1527
- query FindDocuments(
1528
- $search: SearchFilterInput
1529
- $view: ViewFilterInput
1530
- $paging: PagingInput
1531
- ) {
1532
- findDocuments(search: $search, view: $view, paging: $paging) {
1533
- items {
1534
- ...PHDocumentFields
1535
- }
1536
- totalCount
1537
- hasNextPage
1538
- hasPreviousPage
1539
- cursor
1540
- }
1541
- }
1542
- ${PhDocumentFieldsFragmentDoc}
1543
- `;
1544
- const GetDocumentOperationsDocument = gql`
1545
- query GetDocumentOperations(
1546
- $filter: OperationsFilterInput!
1547
- $paging: PagingInput
1548
- ) {
1549
- documentOperations(filter: $filter, paging: $paging) {
1550
- items {
1551
- index
1552
- timestampUtcMs
1553
- hash
1554
- skip
1555
- error
1556
- id
1557
- action {
1558
- id
1559
- type
1560
- timestampUtcMs
1561
- input
1562
- scope
1563
- attachments {
1564
- data
1565
- mimeType
1566
- hash
1567
- extension
1568
- fileName
1569
- }
1570
- context {
1571
- signer {
1572
- user {
1573
- address
1574
- networkId
1575
- chainId
1576
- }
1577
- app {
1578
- name
1579
- key
1580
- }
1581
- signatures
1582
- }
1583
- }
1584
- }
1585
- }
1586
- totalCount
1587
- hasNextPage
1588
- hasPreviousPage
1589
- cursor
1590
- }
1591
- }
1592
- `;
1593
- const GetJobStatusDocument = gql`
1594
- query GetJobStatus($jobId: String!) {
1595
- jobStatus(jobId: $jobId) {
1596
- id
1597
- status
1598
- result
1599
- error
1600
- createdAt
1601
- completedAt
1602
- }
1603
- }
1604
- `;
1605
- const CreateDocumentDocument = gql`
1606
- mutation CreateDocument($document: JSONObject!, $parentIdentifier: String) {
1607
- createDocument(document: $document, parentIdentifier: $parentIdentifier) {
1608
- ...PHDocumentFields
1609
- }
1610
- }
1611
- ${PhDocumentFieldsFragmentDoc}
1612
- `;
1613
- const CreateEmptyDocumentDocument = gql`
1614
- mutation CreateEmptyDocument(
1615
- $documentType: String!
1616
- $parentIdentifier: String
1617
- ) {
1618
- createEmptyDocument(
1619
- documentType: $documentType
1620
- parentIdentifier: $parentIdentifier
1621
- ) {
1622
- ...PHDocumentFields
1623
- }
1624
- }
1625
- ${PhDocumentFieldsFragmentDoc}
1626
- `;
1627
- const MutateDocumentDocument = gql`
1628
- mutation MutateDocument(
1629
- $documentIdentifier: String!
1630
- $actions: [JSONObject!]!
1631
- $view: ViewFilterInput
1632
- ) {
1633
- mutateDocument(
1634
- documentIdentifier: $documentIdentifier
1635
- actions: $actions
1636
- view: $view
1637
- ) {
1638
- ...PHDocumentFields
1639
- }
1640
- }
1641
- ${PhDocumentFieldsFragmentDoc}
1642
- `;
1643
- const MutateDocumentAsyncDocument = gql`
1644
- mutation MutateDocumentAsync(
1645
- $documentIdentifier: String!
1646
- $actions: [JSONObject!]!
1647
- $view: ViewFilterInput
1648
- ) {
1649
- mutateDocumentAsync(
1650
- documentIdentifier: $documentIdentifier
1651
- actions: $actions
1652
- view: $view
1653
- )
1654
- }
1655
- `;
1656
- const RenameDocumentDocument = gql`
1657
- mutation RenameDocument(
1658
- $documentIdentifier: String!
1659
- $name: String!
1660
- $branch: String
1661
- ) {
1662
- renameDocument(
1663
- documentIdentifier: $documentIdentifier
1664
- name: $name
1665
- branch: $branch
1666
- ) {
1667
- ...PHDocumentFields
1668
- }
1669
- }
1670
- ${PhDocumentFieldsFragmentDoc}
1671
- `;
1672
- const AddChildrenDocument = gql`
1673
- mutation AddChildren(
1674
- $parentIdentifier: String!
1675
- $documentIdentifiers: [String!]!
1676
- $branch: String
1677
- ) {
1678
- addChildren(
1679
- parentIdentifier: $parentIdentifier
1680
- documentIdentifiers: $documentIdentifiers
1681
- branch: $branch
1682
- ) {
1683
- ...PHDocumentFields
1684
- }
1685
- }
1686
- ${PhDocumentFieldsFragmentDoc}
1687
- `;
1688
- const RemoveChildrenDocument = gql`
1689
- mutation RemoveChildren(
1690
- $parentIdentifier: String!
1691
- $documentIdentifiers: [String!]!
1692
- $branch: String
1693
- ) {
1694
- removeChildren(
1695
- parentIdentifier: $parentIdentifier
1696
- documentIdentifiers: $documentIdentifiers
1697
- branch: $branch
1698
- ) {
1699
- ...PHDocumentFields
1700
- }
1701
- }
1702
- ${PhDocumentFieldsFragmentDoc}
1703
- `;
1704
- const MoveChildrenDocument = gql`
1705
- mutation MoveChildren(
1706
- $sourceParentIdentifier: String!
1707
- $targetParentIdentifier: String!
1708
- $documentIdentifiers: [String!]!
1709
- $branch: String
1710
- ) {
1711
- moveChildren(
1712
- sourceParentIdentifier: $sourceParentIdentifier
1713
- targetParentIdentifier: $targetParentIdentifier
1714
- documentIdentifiers: $documentIdentifiers
1715
- branch: $branch
1716
- ) {
1717
- source {
1718
- ...PHDocumentFields
1719
- }
1720
- target {
1721
- ...PHDocumentFields
1722
- }
1723
- }
1724
- }
1725
- ${PhDocumentFieldsFragmentDoc}
1726
- `;
1727
- const DeleteDocumentDocument = gql`
1728
- mutation DeleteDocument($identifier: String!, $propagate: PropagationMode) {
1729
- deleteDocument(identifier: $identifier, propagate: $propagate)
1730
- }
1731
- `;
1732
- const DeleteDocumentsDocument = gql`
1733
- mutation DeleteDocuments(
1734
- $identifiers: [String!]!
1735
- $propagate: PropagationMode
1736
- ) {
1737
- deleteDocuments(identifiers: $identifiers, propagate: $propagate)
1738
- }
1739
- `;
1740
- const DocumentChangesDocument = gql`
1741
- subscription DocumentChanges(
1742
- $search: SearchFilterInput
1743
- $view: ViewFilterInput
1744
- ) {
1745
- documentChanges(search: $search, view: $view) {
1746
- type
1747
- documents {
1748
- ...PHDocumentFields
1749
- }
1750
- context {
1751
- parentId
1752
- childId
1753
- }
1754
- }
1755
- }
1756
- ${PhDocumentFieldsFragmentDoc}
1757
- `;
1758
- const JobChangesDocument = gql`
1759
- subscription JobChanges($jobId: String!) {
1760
- jobChanges(jobId: $jobId) {
1761
- jobId
1762
- status
1763
- result
1764
- error
1765
- }
1766
- }
1767
- `;
1768
- const PollSyncEnvelopesDocument = gql`
1769
- query PollSyncEnvelopes(
1770
- $channelId: String!
1771
- $outboxAck: Int!
1772
- $outboxLatest: Int!
1773
- ) {
1774
- pollSyncEnvelopes(
1775
- channelId: $channelId
1776
- outboxAck: $outboxAck
1777
- outboxLatest: $outboxLatest
1778
- ) {
1779
- envelopes {
1780
- type
1781
- channelMeta {
1782
- id
1783
- }
1784
- operations {
1785
- operation {
1786
- index
1787
- timestampUtcMs
1788
- hash
1789
- skip
1790
- error
1791
- id
1792
- action {
1793
- id
1794
- type
1795
- timestampUtcMs
1796
- input
1797
- scope
1798
- attachments {
1799
- data
1800
- mimeType
1801
- hash
1802
- extension
1803
- fileName
1804
- }
1805
- context {
1806
- signer {
1807
- user {
1808
- address
1809
- networkId
1810
- chainId
1811
- }
1812
- app {
1813
- name
1814
- key
1815
- }
1816
- signatures
1817
- }
1818
- }
1819
- }
1820
- }
1821
- context {
1822
- documentId
1823
- documentType
1824
- scope
1825
- branch
1826
- }
1827
- }
1828
- cursor {
1829
- remoteName
1830
- cursorOrdinal
1831
- lastSyncedAtUtcMs
1832
- }
1833
- key
1834
- dependsOn
1835
- }
1836
- ackOrdinal
1837
- deadLetters {
1838
- documentId
1839
- error
1840
- }
1841
- hasMore
1842
- }
1843
- }
1844
- `;
1845
- const TouchChannelDocument = gql`
1846
- mutation TouchChannel($input: TouchChannelInput!) {
1847
- touchChannel(input: $input) {
1848
- success
1849
- ackOrdinal
1850
- }
1851
- }
1852
- `;
1853
- const PushSyncEnvelopesDocument = gql`
1854
- mutation PushSyncEnvelopes($envelopes: [SyncEnvelopeInput!]!) {
1855
- pushSyncEnvelopes(envelopes: $envelopes)
1856
- }
1857
- `;
1858
- const defaultWrapper = (action, _operationName, _operationType, _variables) => action();
1859
- function getSdk(client, withWrapper = defaultWrapper) {
1860
- return {
1861
- GetDocumentModels(variables, requestHeaders, signal) {
1862
- return withWrapper((wrappedRequestHeaders) => client.request({
1863
- document: GetDocumentModelsDocument,
1864
- variables,
1865
- requestHeaders: {
1866
- ...requestHeaders,
1867
- ...wrappedRequestHeaders
1868
- },
1869
- signal
1870
- }), "GetDocumentModels", "query", variables);
1871
- },
1872
- GetDocument(variables, requestHeaders, signal) {
1873
- return withWrapper((wrappedRequestHeaders) => client.request({
1874
- document: GetDocumentDocument,
1875
- variables,
1876
- requestHeaders: {
1877
- ...requestHeaders,
1878
- ...wrappedRequestHeaders
1879
- },
1880
- signal
1881
- }), "GetDocument", "query", variables);
1882
- },
1883
- GetDocumentWithOperations(variables, requestHeaders, signal) {
1884
- return withWrapper((wrappedRequestHeaders) => client.request({
1885
- document: GetDocumentWithOperationsDocument,
1886
- variables,
1887
- requestHeaders: {
1888
- ...requestHeaders,
1889
- ...wrappedRequestHeaders
1890
- },
1891
- signal
1892
- }), "GetDocumentWithOperations", "query", variables);
1893
- },
1894
- GetDocumentChildren(variables, requestHeaders, signal) {
1895
- return withWrapper((wrappedRequestHeaders) => client.request({
1896
- document: GetDocumentChildrenDocument,
1897
- variables,
1898
- requestHeaders: {
1899
- ...requestHeaders,
1900
- ...wrappedRequestHeaders
1901
- },
1902
- signal
1903
- }), "GetDocumentChildren", "query", variables);
1904
- },
1905
- GetDocumentParents(variables, requestHeaders, signal) {
1906
- return withWrapper((wrappedRequestHeaders) => client.request({
1907
- document: GetDocumentParentsDocument,
1908
- variables,
1909
- requestHeaders: {
1910
- ...requestHeaders,
1911
- ...wrappedRequestHeaders
1912
- },
1913
- signal
1914
- }), "GetDocumentParents", "query", variables);
1915
- },
1916
- FindDocuments(variables, requestHeaders, signal) {
1917
- return withWrapper((wrappedRequestHeaders) => client.request({
1918
- document: FindDocumentsDocument,
1919
- variables,
1920
- requestHeaders: {
1921
- ...requestHeaders,
1922
- ...wrappedRequestHeaders
1923
- },
1924
- signal
1925
- }), "FindDocuments", "query", variables);
1926
- },
1927
- GetDocumentOperations(variables, requestHeaders, signal) {
1928
- return withWrapper((wrappedRequestHeaders) => client.request({
1929
- document: GetDocumentOperationsDocument,
1930
- variables,
1931
- requestHeaders: {
1932
- ...requestHeaders,
1933
- ...wrappedRequestHeaders
1934
- },
1935
- signal
1936
- }), "GetDocumentOperations", "query", variables);
1937
- },
1938
- GetJobStatus(variables, requestHeaders, signal) {
1939
- return withWrapper((wrappedRequestHeaders) => client.request({
1940
- document: GetJobStatusDocument,
1941
- variables,
1942
- requestHeaders: {
1943
- ...requestHeaders,
1944
- ...wrappedRequestHeaders
1945
- },
1946
- signal
1947
- }), "GetJobStatus", "query", variables);
1948
- },
1949
- CreateDocument(variables, requestHeaders, signal) {
1950
- return withWrapper((wrappedRequestHeaders) => client.request({
1951
- document: CreateDocumentDocument,
1952
- variables,
1953
- requestHeaders: {
1954
- ...requestHeaders,
1955
- ...wrappedRequestHeaders
1956
- },
1957
- signal
1958
- }), "CreateDocument", "mutation", variables);
1959
- },
1960
- CreateEmptyDocument(variables, requestHeaders, signal) {
1961
- return withWrapper((wrappedRequestHeaders) => client.request({
1962
- document: CreateEmptyDocumentDocument,
1963
- variables,
1964
- requestHeaders: {
1965
- ...requestHeaders,
1966
- ...wrappedRequestHeaders
1967
- },
1968
- signal
1969
- }), "CreateEmptyDocument", "mutation", variables);
1970
- },
1971
- MutateDocument(variables, requestHeaders, signal) {
1972
- return withWrapper((wrappedRequestHeaders) => client.request({
1973
- document: MutateDocumentDocument,
1974
- variables,
1975
- requestHeaders: {
1976
- ...requestHeaders,
1977
- ...wrappedRequestHeaders
1978
- },
1979
- signal
1980
- }), "MutateDocument", "mutation", variables);
1981
- },
1982
- MutateDocumentAsync(variables, requestHeaders, signal) {
1983
- return withWrapper((wrappedRequestHeaders) => client.request({
1984
- document: MutateDocumentAsyncDocument,
1985
- variables,
1986
- requestHeaders: {
1987
- ...requestHeaders,
1988
- ...wrappedRequestHeaders
1989
- },
1990
- signal
1991
- }), "MutateDocumentAsync", "mutation", variables);
1992
- },
1993
- RenameDocument(variables, requestHeaders, signal) {
1994
- return withWrapper((wrappedRequestHeaders) => client.request({
1995
- document: RenameDocumentDocument,
1996
- variables,
1997
- requestHeaders: {
1998
- ...requestHeaders,
1999
- ...wrappedRequestHeaders
2000
- },
2001
- signal
2002
- }), "RenameDocument", "mutation", variables);
2003
- },
2004
- AddChildren(variables, requestHeaders, signal) {
2005
- return withWrapper((wrappedRequestHeaders) => client.request({
2006
- document: AddChildrenDocument,
2007
- variables,
2008
- requestHeaders: {
2009
- ...requestHeaders,
2010
- ...wrappedRequestHeaders
2011
- },
2012
- signal
2013
- }), "AddChildren", "mutation", variables);
2014
- },
2015
- RemoveChildren(variables, requestHeaders, signal) {
2016
- return withWrapper((wrappedRequestHeaders) => client.request({
2017
- document: RemoveChildrenDocument,
2018
- variables,
2019
- requestHeaders: {
2020
- ...requestHeaders,
2021
- ...wrappedRequestHeaders
2022
- },
2023
- signal
2024
- }), "RemoveChildren", "mutation", variables);
2025
- },
2026
- MoveChildren(variables, requestHeaders, signal) {
2027
- return withWrapper((wrappedRequestHeaders) => client.request({
2028
- document: MoveChildrenDocument,
2029
- variables,
2030
- requestHeaders: {
2031
- ...requestHeaders,
2032
- ...wrappedRequestHeaders
2033
- },
2034
- signal
2035
- }), "MoveChildren", "mutation", variables);
2036
- },
2037
- DeleteDocument(variables, requestHeaders, signal) {
2038
- return withWrapper((wrappedRequestHeaders) => client.request({
2039
- document: DeleteDocumentDocument,
2040
- variables,
2041
- requestHeaders: {
2042
- ...requestHeaders,
2043
- ...wrappedRequestHeaders
2044
- },
2045
- signal
2046
- }), "DeleteDocument", "mutation", variables);
2047
- },
2048
- DeleteDocuments(variables, requestHeaders, signal) {
2049
- return withWrapper((wrappedRequestHeaders) => client.request({
2050
- document: DeleteDocumentsDocument,
2051
- variables,
2052
- requestHeaders: {
2053
- ...requestHeaders,
2054
- ...wrappedRequestHeaders
2055
- },
2056
- signal
2057
- }), "DeleteDocuments", "mutation", variables);
2058
- },
2059
- DocumentChanges(variables, requestHeaders, signal) {
2060
- return withWrapper((wrappedRequestHeaders) => client.request({
2061
- document: DocumentChangesDocument,
2062
- variables,
2063
- requestHeaders: {
2064
- ...requestHeaders,
2065
- ...wrappedRequestHeaders
2066
- },
2067
- signal
2068
- }), "DocumentChanges", "subscription", variables);
2069
- },
2070
- JobChanges(variables, requestHeaders, signal) {
2071
- return withWrapper((wrappedRequestHeaders) => client.request({
2072
- document: JobChangesDocument,
2073
- variables,
2074
- requestHeaders: {
2075
- ...requestHeaders,
2076
- ...wrappedRequestHeaders
2077
- },
2078
- signal
2079
- }), "JobChanges", "subscription", variables);
2080
- },
2081
- PollSyncEnvelopes(variables, requestHeaders, signal) {
2082
- return withWrapper((wrappedRequestHeaders) => client.request({
2083
- document: PollSyncEnvelopesDocument,
2084
- variables,
2085
- requestHeaders: {
2086
- ...requestHeaders,
2087
- ...wrappedRequestHeaders
2088
- },
2089
- signal
2090
- }), "PollSyncEnvelopes", "query", variables);
2091
- },
2092
- TouchChannel(variables, requestHeaders, signal) {
2093
- return withWrapper((wrappedRequestHeaders) => client.request({
2094
- document: TouchChannelDocument,
2095
- variables,
2096
- requestHeaders: {
2097
- ...requestHeaders,
2098
- ...wrappedRequestHeaders
2099
- },
2100
- signal
2101
- }), "TouchChannel", "mutation", variables);
2102
- },
2103
- PushSyncEnvelopes(variables, requestHeaders, signal) {
2104
- return withWrapper((wrappedRequestHeaders) => client.request({
2105
- document: PushSyncEnvelopesDocument,
2106
- variables,
2107
- requestHeaders: {
2108
- ...requestHeaders,
2109
- ...wrappedRequestHeaders
2110
- },
2111
- signal
2112
- }), "PushSyncEnvelopes", "mutation", variables);
2113
- }
2114
- };
2115
- }
2116
- //#endregion
2117
- //#region src/graphql/batch-queries.ts
2118
- /** Get the source string from a GraphQL document (string or DocumentNode). */
2119
- function getDocumentSource(doc) {
2120
- return typeof doc === "string" ? doc : doc.loc?.source.body ?? "";
2121
- }
2122
- /**
2123
- * Extract the inner selection set of a named field from a GraphQL document source.
2124
- * Returns the `{ ... }` block including braces.
2125
- */
2126
- function extractSelectionSet(doc, fieldName, fallback) {
2127
- const source = getDocumentSource(doc);
2128
- return new RegExp(`${fieldName}\\([^)]*\\)\\s*(\\{[\\s\\S]*\\})\\s*\\}`).exec(source)?.[1] ?? fallback;
2129
- }
2130
- /**
2131
- * Extract the query body and any fragment definitions from a GraphQL document.
2132
- * Returns { body, fragments } where body is the content inside the query `{ ... }`
2133
- * and fragments are any trailing fragment definitions.
2134
- */
2135
- function extractQueryParts(doc, fallbackBody) {
2136
- const source = getDocumentSource(doc);
2137
- const queryMatch = /^[^{]*\{([\s\S]*?)\}\s*(fragment[\s\S]*)?$/.exec(source);
2138
- return {
2139
- body: queryMatch?.[1]?.trim() ?? fallbackBody,
2140
- fragments: queryMatch?.[2]?.trim() ?? ""
2141
- };
2142
- }
2143
- const operationsSelectionSet = extractSelectionSet(GetDocumentOperationsDocument, "documentOperations", "{ items { index } }");
2144
- const documentParts = extractQueryParts(GetDocumentDocument, "document(identifier: $identifier) { document { id name documentType state revisionsList { scope revision } createdAtUtcIso lastModifiedAtUtcIso } childIds }");
2145
- /**
2146
- * Build a single GraphQL query that fetches documentOperations for
2147
- * multiple filters using aliases. Each filter gets its own alias
2148
- * (`scope_0`, `scope_1`, …) so all scopes are fetched in one HTTP request.
2149
- */
2150
- function buildBatchOperationsQuery(filters, pagings) {
2151
- const query = `query BatchGetDocumentOperations(${filters.flatMap((_, i) => [`$filter_${i}: OperationsFilterInput!`, `$paging_${i}: PagingInput`]).join(", ")}) {
2152
- ${filters.map((_, i) => `scope_${i}: documentOperations(filter: $filter_${i}, paging: $paging_${i}) ${operationsSelectionSet}`).join("\n ")}
2153
- }`;
2154
- const variables = {};
2155
- for (let i = 0; i < filters.length; i++) {
2156
- variables[`filter_${i}`] = filters[i];
2157
- variables[`paging_${i}`] = pagings[i] ?? null;
2158
- }
2159
- return {
2160
- query,
2161
- variables
2162
- };
2163
- }
2164
- /**
2165
- * Build a single GraphQL query that fetches a document AND
2166
- * documentOperations for multiple filters, all in one HTTP request.
2167
- */
2168
- function buildBatchDocumentWithOperationsQuery(identifier, view, filters, pagings) {
2169
- const docVarDefs = "$identifier: String!, $view: ViewFilterInput";
2170
- const opsVarDefs = filters.flatMap((_, i) => [`$filter_${i}: OperationsFilterInput!`, `$paging_${i}: PagingInput`]).join(", ");
2171
- const opsFields = filters.map((_, i) => `scope_${i}: documentOperations(filter: $filter_${i}, paging: $paging_${i}) ${operationsSelectionSet}`).join("\n ");
2172
- const query = `query BatchGetDocumentWithOperations(${docVarDefs}, ${opsVarDefs}) {
2173
- ${documentParts.body}
2174
- ${opsFields}
2175
- }
2176
- ${documentParts.fragments}`;
2177
- const variables = {
2178
- identifier,
2179
- view: view ?? null
2180
- };
2181
- for (let i = 0; i < filters.length; i++) {
2182
- variables[`filter_${i}`] = filters[i];
2183
- variables[`paging_${i}`] = pagings[i] ?? null;
2184
- }
2185
- return {
2186
- query,
2187
- variables
2188
- };
2189
- }
2190
- //#endregion
2191
- //#region src/graphql/client.ts
2192
- /**
2193
- * Creates a GraphQL client for the Reactor Subgraph API.
2194
- * @param urlOrGQLClient The URL of the GraphQL API or a GraphQL client instance.
2195
- * @param middleware An optional middleware function to wrap the GraphQL client calls.
2196
- * @returns A GraphQL client for the Reactor Subgraph API.
2197
- */
2198
- function createClient(urlOrGQLClient, middleware) {
2199
- const client = typeof urlOrGQLClient === "string" ? new GraphQLClient(urlOrGQLClient) : urlOrGQLClient;
2200
- const runWithMiddleware = async (operationName, run) => {
2201
- if (!middleware) return run();
2202
- return middleware(run, operationName, "query");
2203
- };
2204
- return {
2205
- ...getSdk(client, middleware),
2206
- async BatchGetDocumentOperations(filters, pagings) {
2207
- const { query, variables } = buildBatchOperationsQuery(filters, pagings);
2208
- const data = await runWithMiddleware("BatchGetDocumentOperations", (requestHeaders) => client.request(query, variables, requestHeaders));
2209
- return filters.map((_, i) => data[`scope_${i}`]);
2210
- },
2211
- async BatchGetDocumentWithOperations(identifier, view, filters, pagings) {
2212
- const { query, variables } = buildBatchDocumentWithOperationsQuery(identifier, view, filters, pagings);
2213
- const data = await runWithMiddleware("BatchGetDocumentWithOperations", (requestHeaders) => client.request(query, variables, requestHeaders));
2214
- return {
2215
- document: data.document ?? null,
2216
- operations: filters.map((_, i) => data[`scope_${i}`])
2217
- };
2218
- }
2219
- };
2220
- }
2221
- //#endregion
2222
- //#region src/hooks/loading.ts
2223
- const { useValue: useLoading, setValue: setLoading, addEventHandler: addLoadingEventHandler } = makePHEventFunctions("loading");
2224
- const loading = null;
2225
- //#endregion
2226
- //#region src/hooks/renown.ts
2227
- const renownEventFunctions = makePHEventFunctions("renown");
2228
- /** Adds an event handler for the renown instance */
2229
- const addRenownEventHandler = renownEventFunctions.addEventHandler;
2230
- /** Returns the renown instance */
2231
- const useRenown = renownEventFunctions.useValue;
2232
- /** Sets the renown instance */
2233
- const setRenown = renownEventFunctions.setValue;
2234
- /** Returns the DID from the renown instance */
2235
- function useDid() {
2236
- return useRenown()?.did;
2237
- }
2238
- /** Returns the current user from the renown instance, subscribing to user events */
2239
- function useUser() {
2240
- const renown = useRenown();
2241
- const [user, setUser] = useState(renown?.user);
2242
- useEffect(() => {
2243
- setUser(renown?.user);
2244
- if (!renown) return;
2245
- return renown.on("user", setUser);
2246
- }, [renown]);
2247
- return user;
2248
- }
2249
- /** Returns the login status, subscribing to renown status events */
2250
- function useLoginStatus() {
2251
- const renown = useRenown();
2252
- return useSyncExternalStore((cb) => {
2253
- if (!renown) return () => {};
2254
- return renown.on("status", cb);
2255
- }, () => renown === null ? "loading" : renown?.status, () => void 0);
2256
- }
2257
- //#endregion
2258
- //#region src/renown/constants.ts
2259
- const RENOWN_URL = "https://www.renown.id";
2260
- const RENOWN_NETWORK_ID = "eip155";
2261
- const RENOWN_CHAIN_ID = "1";
2262
- const DOMAIN_TYPE = [
2263
- {
2264
- name: "name",
2265
- type: "string"
2266
- },
2267
- {
2268
- name: "version",
2269
- type: "string"
2270
- },
2271
- {
2272
- name: "chainId",
2273
- type: "uint256"
2274
- },
2275
- {
2276
- name: "verifyingContract",
2277
- type: "address"
2278
- }
2279
- ];
2280
- const VERIFIABLE_CREDENTIAL_EIP712_TYPE = [
2281
- {
2282
- name: "@context",
2283
- type: "string[]"
2284
- },
2285
- {
2286
- name: "type",
2287
- type: "string[]"
2288
- },
2289
- {
2290
- name: "id",
2291
- type: "string"
2292
- },
2293
- {
2294
- name: "issuer",
2295
- type: "Issuer"
2296
- },
2297
- {
2298
- name: "credentialSubject",
2299
- type: "CredentialSubject"
2300
- },
2301
- {
2302
- name: "credentialSchema",
2303
- type: "CredentialSchema"
2304
- },
2305
- {
2306
- name: "issuanceDate",
2307
- type: "string"
2308
- },
2309
- {
2310
- name: "expirationDate",
2311
- type: "string"
2312
- }
2313
- ];
2314
- const CREDENTIAL_SCHEMA_EIP712_TYPE = [{
2315
- name: "id",
2316
- type: "string"
2317
- }, {
2318
- name: "type",
2319
- type: "string"
2320
- }];
2321
- const CREDENTIAL_SUBJECT_TYPE = [
2322
- {
2323
- name: "app",
2324
- type: "string"
2325
- },
2326
- {
2327
- name: "id",
2328
- type: "string"
2329
- },
2330
- {
2331
- name: "name",
2332
- type: "string"
2333
- }
2334
- ];
2335
- const ISSUER_TYPE = [{
2336
- name: "id",
2337
- type: "string"
2338
- }, {
2339
- name: "ethereumAddress",
2340
- type: "string"
2341
- }];
2342
- const CREDENTIAL_TYPES = {
2343
- EIP712Domain: DOMAIN_TYPE,
2344
- VerifiableCredential: VERIFIABLE_CREDENTIAL_EIP712_TYPE,
2345
- CredentialSchema: CREDENTIAL_SCHEMA_EIP712_TYPE,
2346
- CredentialSubject: CREDENTIAL_SUBJECT_TYPE,
2347
- Issuer: ISSUER_TYPE
2348
- };
2349
- //#endregion
2350
- //#region src/renown/utils.ts
2351
- function openRenown(documentId) {
2352
- const renown = window.ph?.renown;
2353
- let renownUrl = renown?.baseUrl;
2354
- if (!renownUrl) {
2355
- logger.warn("Renown instance not found, falling back to: ", RENOWN_URL);
2356
- renownUrl = RENOWN_URL;
2357
- }
2358
- if (documentId) {
2359
- window.open(`${renownUrl}/profile/${documentId}`, "_blank")?.focus();
2360
- return;
2361
- }
2362
- const url = new URL(renownUrl);
2363
- url.searchParams.set("app", renown?.did ?? "");
2364
- url.searchParams.set("connect", renown?.did ?? "");
2365
- url.searchParams.set("network", RENOWN_NETWORK_ID);
2366
- url.searchParams.set("chain", "1");
2367
- const returnUrl = new URL(window.location.pathname, window.location.origin);
2368
- url.searchParams.set("returnUrl", returnUrl.toJSON());
2369
- window.open(url, "_self")?.focus();
2370
- }
2371
- /**
2372
- * Reads the `?user=` DID from the URL if present.
2373
- * Returns the DID and cleans up the URL parameter.
2374
- */
2375
- function consumeDidFromUrl() {
2376
- if (typeof window === "undefined") return;
2377
- const userParam = new URLSearchParams(window.location.search).get("user");
2378
- if (!userParam) return;
2379
- const userDid = decodeURIComponent(userParam);
2380
- const cleanUrl = new URL(window.location.href);
2381
- cleanUrl.searchParams.delete("user");
2382
- window.history.replaceState({}, "", cleanUrl.toString());
2383
- return userDid;
2384
- }
2385
- /**
2386
- * Log in the user. Resolves the user DID from (in order):
2387
- * 1. Explicit `userDid` argument
2388
- * 2. `?user=` URL parameter (from Renown portal redirect)
2389
- * 3. Previously stored session in the Renown instance
2390
- */
2391
- async function login(userDid, renown) {
2392
- if (!renown) return;
2393
- const did = userDid ?? consumeDidFromUrl();
2394
- try {
2395
- const user = renown.user;
2396
- if (user?.did && (user.did === did || !did)) return user;
2397
- if (!did) return;
2398
- return await renown.login(did);
2399
- } catch (error) {
2400
- logger.error(error instanceof Error ? error.message : JSON.stringify(error));
2401
- }
2402
- }
2403
- async function logout() {
2404
- await (window.ph?.renown)?.logout();
2405
- const url = new URL(window.location.href);
2406
- if (url.searchParams.has("user")) {
2407
- url.searchParams.delete("user");
2408
- window.history.replaceState(null, "", url.toString());
2409
- }
2410
- }
2411
- //#endregion
2412
- //#region src/renown/use-renown-auth.ts
2413
- function truncateAddress$1(address) {
2414
- if (address.length <= 13) return address;
2415
- return `${address.slice(0, 7)}...${address.slice(-5)}`;
2416
- }
2417
- function toRenownAuthStatus(loginStatus, user) {
2418
- if (loginStatus === "authorized") return user ? "authorized" : "checking";
2419
- return loginStatus;
2420
- }
2421
- function useRenownAuth() {
2422
- const user = useUser();
2423
- const status = toRenownAuthStatus(useLoginStatus(), user);
2424
- const address = user?.address;
2425
- const ensName = user?.ens?.name;
2426
- const avatarUrl = user?.profile?.userImage ?? user?.ens?.avatarUrl;
2427
- const profileId = user?.profile?.documentId;
2428
- return {
2429
- status,
2430
- user,
2431
- address,
2432
- ensName,
2433
- avatarUrl,
2434
- profileId,
2435
- displayName: ensName ?? user?.profile?.username ?? void 0,
2436
- displayAddress: address ? truncateAddress$1(address) : void 0,
2437
- login: useCallback(() => {
2438
- openRenown();
2439
- }, []),
2440
- logout: useCallback(async () => {
2441
- await logout();
2442
- }, []),
2443
- openProfile: useCallback(() => {
2444
- if (profileId) openRenown(profileId);
2445
- }, [profileId])
2446
- };
2447
- }
2448
- //#endregion
2449
554
  //#region src/hooks/config/editor.ts
2450
555
  const isExternalControlsEnabledEventFunctions = makePHEventFunctions("isExternalControlsEnabled");
2451
556
  /** Sets whether external controls are enabled for a given editor. */
@@ -3936,23 +2041,6 @@ function createDebouncedRefreshReactorDataClient(debounceDelayMs = DEFAULT_DEBOU
3936
2041
  }
3937
2042
  const refreshReactorData = createDebouncedRefreshReactorData();
3938
2043
  const refreshReactorDataClient = createDebouncedRefreshReactorDataClient();
3939
- /**
3940
- * @deprecated Use {@link initRenownCrypto} instead
3941
- *
3942
- * Initialize ConnectCrypto
3943
- * @returns ConnectCrypto instance
3944
- */
3945
- async function initConnectCrypto() {
3946
- return initRenownCrypto();
3947
- }
3948
- /**
3949
- * Initialize RenownCrypto
3950
- * @returns RenownCrypto instance
3951
- */
3952
- async function initRenownCrypto() {
3953
- const keyStorage = await BrowserKeyStorage.create();
3954
- return await new RenownCryptoBuilder().withKeyPairStorage(keyStorage).build();
3955
- }
3956
2044
  //#endregion
3957
2045
  //#region src/registry/fetchers.ts
3958
2046
  function trimTrailingSlash(url) {
@@ -4002,121 +2090,6 @@ var RegistryClient = class {
4002
2090
  }
4003
2091
  };
4004
2092
  //#endregion
4005
- //#region src/pglite/usePGlite.ts
4006
- const PGLITE_UPDATE_EVENT = "ph:pglite-update";
4007
- const defaultPGliteState = {
4008
- db: null,
4009
- isLoading: true,
4010
- error: null
4011
- };
4012
- const usePGliteDB = () => {
4013
- const [state, setState] = useState(() => window.powerhouse?.pglite ?? defaultPGliteState);
4014
- useEffect(() => {
4015
- const handlePgliteUpdate = () => setState(window.powerhouse?.pglite ?? defaultPGliteState);
4016
- window.addEventListener(PGLITE_UPDATE_EVENT, handlePgliteUpdate);
4017
- return () => window.removeEventListener(PGLITE_UPDATE_EVENT, handlePgliteUpdate);
4018
- }, []);
4019
- return state;
4020
- };
4021
- //#endregion
4022
- //#region src/relational/hooks/useRelationalDb.ts
4023
- function createRelationalDbWithLive(pgliteInstance) {
4024
- const relationalDBWithLive = createRelationalDb(new Kysely({ dialect: new PGliteDialect(pgliteInstance) }));
4025
- relationalDBWithLive.live = pgliteInstance.live;
4026
- return relationalDBWithLive;
4027
- }
4028
- const useRelationalDb = () => {
4029
- const pglite = usePGliteDB();
4030
- return useMemo(() => {
4031
- if (!pglite.db || pglite.isLoading || pglite.error) return {
4032
- db: null,
4033
- isLoading: pglite.isLoading,
4034
- error: pglite.error
4035
- };
4036
- return {
4037
- db: createRelationalDbWithLive(pglite.db),
4038
- isLoading: false,
4039
- error: null
4040
- };
4041
- }, [pglite]);
4042
- };
4043
- //#endregion
4044
- //#region src/relational/hooks/useRelationalQuery.ts
4045
- const MAX_RETRIES = 5;
4046
- const RETRY_DELAY = 200;
4047
- const isRelationNotExistError = (error) => {
4048
- const errorMessage = error instanceof Error ? error.message : typeof error === "string" ? error : String(error);
4049
- return errorMessage.toLowerCase().includes("relation") && errorMessage.toLowerCase().includes("does not exist");
4050
- };
4051
- function useRelationalQuery(ProcessorClass, driveId, queryCallback, parameters, options) {
4052
- const [result, setResult] = useState(null);
4053
- const [queryLoading, setQueryLoading] = useState(true);
4054
- const [error, setError] = useState(void 0);
4055
- const retryCount = useRef(0);
4056
- const retryTimeoutRef = useRef(null);
4057
- const relationalDb = useRelationalDb();
4058
- const executeLiveQuery = async (sql, queryParameters, retryAttempt = 0) => {
4059
- if (!relationalDb.db) return null;
4060
- try {
4061
- return await relationalDb.db.live.query(sql, queryParameters ? [...queryParameters] : [], (result) => {
4062
- setResult(result);
4063
- setQueryLoading(false);
4064
- retryCount.current = 0;
4065
- });
4066
- } catch (err) {
4067
- if (isRelationNotExistError(err) && retryAttempt < MAX_RETRIES) return new Promise((resolve) => {
4068
- retryTimeoutRef.current = setTimeout(() => {
4069
- resolve(executeLiveQuery(sql, queryParameters, retryAttempt + 1));
4070
- }, RETRY_DELAY);
4071
- });
4072
- setQueryLoading(false);
4073
- setError(err instanceof Error ? err : new Error(String(err)));
4074
- return null;
4075
- }
4076
- };
4077
- useEffect(() => {
4078
- setError(void 0);
4079
- setQueryLoading(true);
4080
- retryCount.current = 0;
4081
- if (!relationalDb.db) return;
4082
- const { sql, parameters: queryParameters } = queryCallback(ProcessorClass.query(driveId, relationalDb.db), parameters);
4083
- const liveQueryPromise = executeLiveQuery(sql, queryParameters);
4084
- return () => {
4085
- if (retryTimeoutRef.current) clearTimeout(retryTimeoutRef.current);
4086
- liveQueryPromise.then((live) => {
4087
- if (live?.unsubscribe) live.unsubscribe();
4088
- });
4089
- };
4090
- }, [
4091
- relationalDb.db,
4092
- ProcessorClass,
4093
- driveId,
4094
- queryCallback,
4095
- parameters
4096
- ]);
4097
- return {
4098
- isLoading: relationalDb.isLoading || queryLoading,
4099
- error: error || relationalDb.error,
4100
- result
4101
- };
4102
- }
4103
- //#endregion
4104
- //#region src/relational/utils/createProcessorQuery.ts
4105
- function useStableParams(params) {
4106
- const prevParamsRef = useRef(null);
4107
- return useMemo(() => {
4108
- if (!deepEqual(prevParamsRef.current, params)) prevParamsRef.current = params;
4109
- return prevParamsRef.current;
4110
- }, [params]);
4111
- }
4112
- function createProcessorQuery(ProcessorClass) {
4113
- function useQuery(driveId, queryCallback, parameters, options) {
4114
- const stableParams = useStableParams(parameters);
4115
- return useRelationalQuery(ProcessorClass, driveId, useCallback(queryCallback, [stableParams]), stableParams, options);
4116
- }
4117
- return useQuery;
4118
- }
4119
- //#endregion
4120
2093
  //#region src/remote-controller/action-tracker.ts
4121
2094
  /**
4122
2095
  * Tracks pending actions with their operation context (prevOpHash, prevOpIndex).
@@ -4802,766 +2775,6 @@ var RemoteDocumentController = class RemoteDocumentController {
4802
2775
  }
4803
2776
  };
4804
2777
  //#endregion
4805
- //#region src/renown/components/icons.tsx
4806
- function RenownLogo({ width = 71, height = 19, hovered = false, color = "currentColor", className }) {
4807
- return /* @__PURE__ */ jsxs("svg", {
4808
- width,
4809
- height,
4810
- viewBox: "0 0 71 19",
4811
- fill: color,
4812
- xmlns: "http://www.w3.org/2000/svg",
4813
- className,
4814
- children: [
4815
- /* @__PURE__ */ jsx("path", { d: "M53.6211 18.4887V9.0342H56.435V10.8096H56.4923C56.7377 10.181 57.1085 9.70244 57.6047 9.37398C58.101 9.03986 58.6981 8.8728 59.3962 8.8728C60.4105 8.8728 61.2039 9.1871 61.7765 9.8157C62.3546 10.4443 62.6436 11.3164 62.6436 12.432V18.4887H59.7397V13.0776C59.7397 12.5283 59.6007 12.1007 59.3225 11.7949C59.0499 11.4835 58.6654 11.3277 58.1692 11.3277C57.6784 11.3277 57.2803 11.4976 56.9749 11.8374C56.6695 12.1772 56.5168 12.6161 56.5168 13.1541V18.4887H53.6211Z" }),
4816
- /* @__PURE__ */ jsx("path", { d: "M53.097 9.03394L50.7412 18.4884H47.6164L46.1522 12.075H46.0949L44.6389 18.4884H41.5632L39.1992 9.03394H42.1195L43.3056 15.7532H43.3628L44.7861 9.03394H47.551L48.9906 15.7532H49.0479L50.234 9.03394H53.097Z" }),
4817
- /* @__PURE__ */ jsx("path", { d: "M37.8661 17.3926C37.0427 18.2591 35.9084 18.6923 34.4632 18.6923C33.0181 18.6923 31.8838 18.2591 31.0604 17.3926C30.2369 16.5205 29.8252 15.3086 29.8252 13.7569C29.8252 12.2336 30.2424 11.033 31.0767 10.1552C31.9111 9.2718 33.0399 8.83008 34.4632 8.83008C35.892 8.83008 37.0208 9.26896 37.8497 10.1467C38.6841 11.0188 39.1013 12.2222 39.1013 13.7569C39.1013 15.3143 38.6896 16.5262 37.8661 17.3926ZM33.2117 15.7702C33.5116 16.2402 33.9288 16.4752 34.4632 16.4752C34.9977 16.4752 35.4148 16.2402 35.7148 15.7702C36.0147 15.2945 36.1647 14.6234 36.1647 13.7569C36.1647 12.9131 36.012 12.2506 35.7066 11.7692C35.4012 11.2878 34.9868 11.0472 34.4632 11.0472C33.9343 11.0472 33.5171 11.2878 33.2117 11.7692C32.9118 12.2449 32.7618 12.9075 32.7618 13.7569C32.7618 14.6234 32.9118 15.2945 33.2117 15.7702Z" }),
4818
- /* @__PURE__ */ jsx("path", { d: "M20.0088 18.4887V9.0342H22.8227V10.8096H22.88C23.1254 10.181 23.4962 9.70244 23.9924 9.37398C24.4887 9.03986 25.0858 8.8728 25.7838 8.8728C26.7982 8.8728 27.5916 9.1871 28.1642 9.8157C28.7423 10.4443 29.0313 11.3164 29.0313 12.432V18.4887H26.1274V13.0776C26.1274 12.5283 25.9883 12.1007 25.7102 11.7949C25.4376 11.4835 25.0531 11.3277 24.5569 11.3277C24.0661 11.3277 23.668 11.4976 23.3626 11.8374C23.0572 12.1772 22.9045 12.6161 22.9045 13.1541V18.4887H20.0088Z" }),
4819
- /* @__PURE__ */ jsx("path", { d: "M14.7486 10.9707C14.2851 10.9707 13.8952 11.1321 13.5789 11.4549C13.2626 11.7777 13.0854 12.1911 13.0472 12.6951H16.4337C16.4064 12.1741 16.2374 11.7579 15.9265 11.4464C15.6212 11.1293 15.2285 10.9707 14.7486 10.9707ZM16.4991 15.5153H19.1167C18.9749 16.4837 18.5141 17.2567 17.7343 17.8343C16.9599 18.4063 15.9838 18.6923 14.8059 18.6923C13.3662 18.6923 12.2374 18.2591 11.4194 17.3926C10.6014 16.5262 10.1924 15.3313 10.1924 13.8079C10.1924 12.2845 10.5987 11.0755 11.4112 10.1807C12.2237 9.28029 13.3226 8.83008 14.7077 8.83008C16.0656 8.83008 17.1481 9.26047 17.9552 10.1213C18.7677 10.9764 19.174 12.1231 19.174 13.5616V14.4195H13.0145V14.6064C13.0145 15.184 13.1835 15.6541 13.5216 16.0165C13.8597 16.3733 14.3015 16.5517 14.8468 16.5517C15.2503 16.5517 15.5993 16.461 15.8938 16.2798C16.1883 16.0929 16.3901 15.8381 16.4991 15.5153Z" }),
4820
- /* @__PURE__ */ jsx("path", { d: "M3.00205 8.58396V12.0667H4.7771C5.32789 12.0667 5.7587 11.911 6.06954 11.5995C6.38038 11.2881 6.5358 10.8662 6.5358 10.3338C6.5358 9.80718 6.37492 9.38528 6.05318 9.06815C5.73143 8.74535 5.30335 8.58396 4.76892 8.58396H3.00205ZM3.00205 14.1989V18.4886H0V6.23096H5.07158C6.53307 6.23096 7.65373 6.5849 8.43355 7.29278C9.21337 8.00066 9.60328 8.99453 9.60328 10.2744C9.60328 11.0446 9.42605 11.7439 9.07159 12.3725C8.71712 12.9955 8.2236 13.4514 7.59101 13.7402L9.94684 18.4886H6.5767L4.55624 14.1989H3.00205Z" }),
4821
- /* @__PURE__ */ jsx("path", {
4822
- d: "M65.7255 0.211478C65.0841 2.46724 63.3737 4.2455 61.2041 4.90969C60.932 4.99366 60.932 5.39096 61.2041 5.47492C63.3725 6.13912 65.0841 7.91738 65.7255 10.1731C65.8056 10.4551 66.1932 10.4551 66.2745 10.1731C66.9159 7.91738 68.6263 6.13912 70.7959 5.47492C71.068 5.39096 71.068 4.99366 70.7959 4.90969C68.6276 4.2455 66.9159 2.46724 66.2745 0.211478C66.1944 -0.0704925 65.8068 -0.0704925 65.7255 0.211478Z",
4823
- fill: hovered ? "#21FFB4" : color
4824
- })
4825
- ]
4826
- });
4827
- }
4828
- function CopyIcon({ size = 14, color = "#9EA0A1" }) {
4829
- return /* @__PURE__ */ jsxs("svg", {
4830
- width: size,
4831
- height: size,
4832
- viewBox: "0 0 16 16",
4833
- fill: "none",
4834
- xmlns: "http://www.w3.org/2000/svg",
4835
- children: [/* @__PURE__ */ jsx("rect", {
4836
- x: "5",
4837
- y: "5",
4838
- width: "9",
4839
- height: "9",
4840
- rx: "1",
4841
- stroke: color,
4842
- strokeWidth: "1.5"
4843
- }), /* @__PURE__ */ jsx("path", {
4844
- d: "M11 5V3C11 2.44772 10.5523 2 10 2H3C2.44772 2 2 2.44772 2 3V10C2 10.5523 2.44772 11 3 11H5",
4845
- stroke: color,
4846
- strokeWidth: "1.5"
4847
- })]
4848
- });
4849
- }
4850
- function DisconnectIcon({ size = 14, color = "#EA4335" }) {
4851
- return /* @__PURE__ */ jsxs("svg", {
4852
- width: size,
4853
- height: size,
4854
- viewBox: "0 0 16 16",
4855
- fill: "none",
4856
- xmlns: "http://www.w3.org/2000/svg",
4857
- children: [
4858
- /* @__PURE__ */ jsx("path", {
4859
- d: "M6 14H3.33333C2.97971 14 2.64057 13.8595 2.39052 13.6095C2.14048 13.3594 2 13.0203 2 12.6667V3.33333C2 2.97971 2.14048 2.64057 2.39052 2.39052C2.64057 2.14048 2.97971 2 3.33333 2H6",
4860
- stroke: color,
4861
- strokeWidth: "1.5",
4862
- strokeLinecap: "round",
4863
- strokeLinejoin: "round"
4864
- }),
4865
- /* @__PURE__ */ jsx("path", {
4866
- d: "M10.6667 11.3333L14 8L10.6667 4.66667",
4867
- stroke: color,
4868
- strokeWidth: "1.5",
4869
- strokeLinecap: "round",
4870
- strokeLinejoin: "round"
4871
- }),
4872
- /* @__PURE__ */ jsx("path", {
4873
- d: "M14 8H6",
4874
- stroke: color,
4875
- strokeWidth: "1.5",
4876
- strokeLinecap: "round",
4877
- strokeLinejoin: "round"
4878
- })
4879
- ]
4880
- });
4881
- }
4882
- function SpinnerIcon({ size = 14, color = "currentColor" }) {
4883
- return /* @__PURE__ */ jsxs("svg", {
4884
- width: size,
4885
- height: size,
4886
- viewBox: "0 0 16 16",
4887
- fill: "none",
4888
- xmlns: "http://www.w3.org/2000/svg",
4889
- style: { animation: "spin 1s linear infinite" },
4890
- children: [
4891
- /* @__PURE__ */ jsx("style", { children: `@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }` }),
4892
- /* @__PURE__ */ jsx("path", {
4893
- d: "M8 1V4",
4894
- stroke: color,
4895
- strokeWidth: "1.5",
4896
- strokeLinecap: "round"
4897
- }),
4898
- /* @__PURE__ */ jsx("path", {
4899
- d: "M8 12V15",
4900
- stroke: color,
4901
- strokeWidth: "1.5",
4902
- strokeLinecap: "round",
4903
- opacity: "0.3"
4904
- }),
4905
- /* @__PURE__ */ jsx("path", {
4906
- d: "M3.05 3.05L5.17 5.17",
4907
- stroke: color,
4908
- strokeWidth: "1.5",
4909
- strokeLinecap: "round",
4910
- opacity: "0.9"
4911
- }),
4912
- /* @__PURE__ */ jsx("path", {
4913
- d: "M10.83 10.83L12.95 12.95",
4914
- stroke: color,
4915
- strokeWidth: "1.5",
4916
- strokeLinecap: "round",
4917
- opacity: "0.4"
4918
- }),
4919
- /* @__PURE__ */ jsx("path", {
4920
- d: "M1 8H4",
4921
- stroke: color,
4922
- strokeWidth: "1.5",
4923
- strokeLinecap: "round",
4924
- opacity: "0.8"
4925
- }),
4926
- /* @__PURE__ */ jsx("path", {
4927
- d: "M12 8H15",
4928
- stroke: color,
4929
- strokeWidth: "1.5",
4930
- strokeLinecap: "round",
4931
- opacity: "0.5"
4932
- }),
4933
- /* @__PURE__ */ jsx("path", {
4934
- d: "M3.05 12.95L5.17 10.83",
4935
- stroke: color,
4936
- strokeWidth: "1.5",
4937
- strokeLinecap: "round",
4938
- opacity: "0.7"
4939
- }),
4940
- /* @__PURE__ */ jsx("path", {
4941
- d: "M10.83 5.17L12.95 3.05",
4942
- stroke: color,
4943
- strokeWidth: "1.5",
4944
- strokeLinecap: "round",
4945
- opacity: "0.6"
4946
- })
4947
- ]
4948
- });
4949
- }
4950
- function ChevronDownIcon({ size = 14, color = "currentColor", style }) {
4951
- return /* @__PURE__ */ jsx("svg", {
4952
- width: size,
4953
- height: size,
4954
- viewBox: "0 0 16 16",
4955
- fill: "none",
4956
- xmlns: "http://www.w3.org/2000/svg",
4957
- style,
4958
- children: /* @__PURE__ */ jsx("path", {
4959
- d: "M4 6L8 10L12 6",
4960
- stroke: color,
4961
- strokeWidth: "1.5",
4962
- strokeLinecap: "round",
4963
- strokeLinejoin: "round"
4964
- })
4965
- });
4966
- }
4967
- function UserIcon({ size = 24, color = "#6366f1" }) {
4968
- return /* @__PURE__ */ jsxs("svg", {
4969
- width: size,
4970
- height: size,
4971
- viewBox: "0 0 24 24",
4972
- fill: "none",
4973
- xmlns: "http://www.w3.org/2000/svg",
4974
- children: [/* @__PURE__ */ jsx("circle", {
4975
- cx: "12",
4976
- cy: "8",
4977
- r: "4",
4978
- stroke: color,
4979
- strokeWidth: "2"
4980
- }), /* @__PURE__ */ jsx("path", {
4981
- d: "M4 20C4 16.6863 7.58172 14 12 14C16.4183 14 20 16.6863 20 20",
4982
- stroke: color,
4983
- strokeWidth: "2",
4984
- strokeLinecap: "round"
4985
- })]
4986
- });
4987
- }
4988
- //#endregion
4989
- //#region src/renown/components/slot.tsx
4990
- function mergeProps(parentProps, childProps) {
4991
- const merged = { ...parentProps };
4992
- for (const key of Object.keys(childProps)) {
4993
- const parentValue = parentProps[key];
4994
- const childValue = childProps[key];
4995
- if (key === "style") merged[key] = {
4996
- ...parentValue,
4997
- ...childValue
4998
- };
4999
- else if (key === "className") merged[key] = [parentValue, childValue].filter(Boolean).join(" ");
5000
- else if (typeof parentValue === "function" && typeof childValue === "function") merged[key] = (...args) => {
5001
- childValue(...args);
5002
- parentValue(...args);
5003
- };
5004
- else if (childValue !== void 0) merged[key] = childValue;
5005
- }
5006
- return merged;
5007
- }
5008
- const Slot = forwardRef(({ children, ...props }, ref) => {
5009
- const child = Children.only(children);
5010
- if (!isValidElement(child)) return null;
5011
- const childElement = child;
5012
- const mergedProps = mergeProps(props, childElement.props);
5013
- if (ref) mergedProps.ref = ref;
5014
- return cloneElement(childElement, mergedProps);
5015
- });
5016
- Slot.displayName = "Slot";
5017
- //#endregion
5018
- //#region src/renown/components/RenownLoginButton.tsx
5019
- const lightStyles = {
5020
- trigger: {
5021
- backgroundColor: "#ffffff",
5022
- borderWidth: "1px",
5023
- borderStyle: "solid",
5024
- borderColor: "#d1d5db",
5025
- color: "#111827"
5026
- },
5027
- triggerHover: {
5028
- backgroundColor: "#ecf3f8",
5029
- borderColor: "#9ca3af"
5030
- }
5031
- };
5032
- const darkStyles = {
5033
- trigger: {
5034
- backgroundColor: "#1f2937",
5035
- borderWidth: "1px",
5036
- borderStyle: "solid",
5037
- borderColor: "#4b5563",
5038
- color: "#ecf3f8"
5039
- },
5040
- triggerHover: {
5041
- backgroundColor: "#374151",
5042
- borderColor: "#6b7280"
5043
- }
5044
- };
5045
- const styles$1 = {
5046
- wrapper: {
5047
- position: "relative",
5048
- display: "inline-block"
5049
- },
5050
- trigger: {
5051
- display: "flex",
5052
- alignItems: "center",
5053
- justifyContent: "center",
5054
- gap: "8px",
5055
- padding: "8px 32px",
5056
- borderRadius: "8px",
5057
- cursor: "pointer",
5058
- fontSize: "14px",
5059
- fontWeight: 500,
5060
- fontFamily: "inherit",
5061
- lineHeight: "20px",
5062
- transition: "background-color 150ms, border-color 150ms"
5063
- }
5064
- };
5065
- function RenownLoginButton({ onLogin: onLoginProp, darkMode = false, style, className, asChild = false, children }) {
5066
- const onLogin = onLoginProp ?? (() => openRenown());
5067
- const [isLoading, setIsLoading] = useState(false);
5068
- const [isHovered, setIsHovered] = useState(false);
5069
- const handleMouseEnter = useCallback(() => setIsHovered(true), []);
5070
- const handleMouseLeave = useCallback(() => setIsHovered(false), []);
5071
- const handleClick = () => {
5072
- if (!isLoading) {
5073
- setIsLoading(true);
5074
- onLogin();
5075
- }
5076
- };
5077
- const themeStyles = darkMode ? darkStyles : lightStyles;
5078
- const triggerStyle = {
5079
- ...styles$1.trigger,
5080
- ...themeStyles.trigger,
5081
- ...isHovered && !isLoading ? themeStyles.triggerHover : {},
5082
- cursor: isLoading ? "wait" : "pointer",
5083
- ...style
5084
- };
5085
- const triggerElement = asChild ? /* @__PURE__ */ jsx(Slot, {
5086
- onClick: handleClick,
5087
- "data-renown-state": "login",
5088
- ...isLoading ? { "data-loading": "" } : {},
5089
- children
5090
- }) : /* @__PURE__ */ jsx("button", {
5091
- type: "button",
5092
- style: triggerStyle,
5093
- "aria-label": "Log in with Renown",
5094
- onClick: handleClick,
5095
- "data-renown-state": "login",
5096
- ...isLoading ? { "data-loading": "" } : {},
5097
- children: isLoading ? /* @__PURE__ */ jsx(SpinnerIcon, { size: 16 }) : /* @__PURE__ */ jsx("span", { children: "Log in" })
5098
- });
5099
- return /* @__PURE__ */ jsx("div", {
5100
- style: styles$1.wrapper,
5101
- className,
5102
- onMouseEnter: handleMouseEnter,
5103
- onMouseLeave: handleMouseLeave,
5104
- children: triggerElement
5105
- });
5106
- }
5107
- //#endregion
5108
- //#region src/renown/components/RenownUserButton.tsx
5109
- const POPOVER_GAP = 4;
5110
- const POPOVER_HEIGHT = 150;
5111
- const styles = {
5112
- wrapper: {
5113
- position: "relative",
5114
- display: "inline-block"
5115
- },
5116
- trigger: {
5117
- display: "flex",
5118
- alignItems: "center",
5119
- gap: "8px",
5120
- padding: "6px 12px",
5121
- borderWidth: "1px",
5122
- borderStyle: "solid",
5123
- borderColor: "#e5e7eb",
5124
- backgroundColor: "#ffffff",
5125
- cursor: "pointer",
5126
- borderRadius: "8px",
5127
- fontSize: "12px",
5128
- fontWeight: 500,
5129
- fontFamily: "inherit",
5130
- color: "#111827",
5131
- transition: "background-color 150ms, border-color 150ms"
5132
- },
5133
- triggerHover: {
5134
- backgroundColor: "#f9fafb",
5135
- borderColor: "#9ca3af"
5136
- },
5137
- avatar: {
5138
- width: "28px",
5139
- height: "28px",
5140
- borderRadius: "50%",
5141
- objectFit: "cover",
5142
- flexShrink: 0
5143
- },
5144
- avatarPlaceholder: {
5145
- width: "28px",
5146
- height: "28px",
5147
- borderRadius: "50%",
5148
- background: "linear-gradient(135deg, #8b5cf6, #3b82f6)",
5149
- display: "flex",
5150
- alignItems: "center",
5151
- justifyContent: "center",
5152
- flexShrink: 0
5153
- },
5154
- avatarInitial: {
5155
- fontSize: "12px",
5156
- fontWeight: 700,
5157
- color: "#ffffff",
5158
- lineHeight: 1
5159
- },
5160
- displayName: {
5161
- maxWidth: "120px",
5162
- overflow: "hidden",
5163
- textOverflow: "ellipsis",
5164
- whiteSpace: "nowrap"
5165
- },
5166
- chevron: {
5167
- flexShrink: 0,
5168
- transition: "transform 150ms",
5169
- color: "#6b7280"
5170
- },
5171
- chevronOpen: { transform: "rotate(180deg)" },
5172
- popoverBase: {
5173
- position: "absolute",
5174
- right: 0,
5175
- backgroundColor: "#ffffff",
5176
- borderRadius: "8px",
5177
- boxShadow: "0 4px 12px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08)",
5178
- width: "100%",
5179
- zIndex: 1e3,
5180
- color: "#111827",
5181
- borderWidth: "1px",
5182
- borderStyle: "solid",
5183
- borderColor: "#e5e7eb",
5184
- overflow: "hidden"
5185
- },
5186
- header: {
5187
- padding: "12px 16px",
5188
- borderBottom: "1px solid #e5e7eb"
5189
- },
5190
- headerUsername: {
5191
- fontSize: "14px",
5192
- fontWeight: 600,
5193
- color: "#111827",
5194
- margin: 0
5195
- },
5196
- addressRow: {
5197
- display: "flex",
5198
- alignItems: "center",
5199
- gap: "4px",
5200
- marginTop: "4px"
5201
- },
5202
- addressButton: {
5203
- display: "flex",
5204
- alignItems: "center",
5205
- gap: "4px",
5206
- padding: 0,
5207
- border: "none",
5208
- backgroundColor: "transparent",
5209
- cursor: "pointer",
5210
- fontSize: "12px",
5211
- color: "#6b7280",
5212
- fontFamily: "inherit",
5213
- position: "relative",
5214
- width: "100%"
5215
- },
5216
- copiedText: {
5217
- fontSize: "12px",
5218
- color: "#059669",
5219
- position: "absolute",
5220
- left: 0,
5221
- transition: "opacity 150ms",
5222
- fontWeight: 500
5223
- },
5224
- addressText: {
5225
- display: "flex",
5226
- alignItems: "center",
5227
- gap: "4px",
5228
- transition: "opacity 150ms"
5229
- },
5230
- menuSection: { padding: "4px 0" },
5231
- menuItem: {
5232
- display: "flex",
5233
- alignItems: "center",
5234
- gap: "8px",
5235
- width: "100%",
5236
- padding: "8px 16px",
5237
- border: "none",
5238
- backgroundColor: "transparent",
5239
- cursor: "pointer",
5240
- fontSize: "14px",
5241
- color: "#374151",
5242
- textDecoration: "none",
5243
- fontFamily: "inherit",
5244
- transition: "background-color 150ms"
5245
- },
5246
- menuItemHover: { backgroundColor: "#f3f4f6" },
5247
- disconnectItem: { color: "#dc2626" },
5248
- separator: {
5249
- height: "1px",
5250
- backgroundColor: "#e5e7eb",
5251
- margin: 0,
5252
- border: "none"
5253
- }
5254
- };
5255
- function truncateAddress(address) {
5256
- if (address.length <= 13) return address;
5257
- return `${address.slice(0, 7)}...${address.slice(-5)}`;
5258
- }
5259
- function RenownUserButton({ address: addressProp, username: usernameProp, avatarUrl: avatarUrlProp, userId: userIdProp, onDisconnect: onDisconnectProp, style, className, asChild = false, children, menuItems }) {
5260
- const user = useUser();
5261
- const address = addressProp ?? user?.address ?? "";
5262
- const username = usernameProp ?? user?.profile?.username ?? user?.ens?.name;
5263
- const avatarUrl = avatarUrlProp ?? user?.profile?.userImage ?? user?.ens?.avatarUrl;
5264
- const userId = userIdProp ?? user?.profile?.documentId;
5265
- const onDisconnect = onDisconnectProp ?? (() => void logout());
5266
- const displayName = username ?? (address ? truncateAddress(address) : "Account");
5267
- const profileId = userId ?? address;
5268
- const [isOpen, setIsOpen] = useState(false);
5269
- const [isHovered, setIsHovered] = useState(false);
5270
- const [isCopied, setIsCopied] = useState(false);
5271
- const [showAbove, setShowAbove] = useState(true);
5272
- const [hoveredItem, setHoveredItem] = useState(null);
5273
- const wrapperRef = useRef(null);
5274
- const closeTimeoutRef = useRef(null);
5275
- const calculatePosition = useCallback(() => {
5276
- if (!wrapperRef.current) return;
5277
- const spaceAbove = wrapperRef.current.getBoundingClientRect().top;
5278
- setShowAbove(spaceAbove >= POPOVER_HEIGHT + POPOVER_GAP);
5279
- }, []);
5280
- const handleMouseEnter = useCallback(() => {
5281
- setIsHovered(true);
5282
- if (closeTimeoutRef.current) {
5283
- clearTimeout(closeTimeoutRef.current);
5284
- closeTimeoutRef.current = null;
5285
- }
5286
- calculatePosition();
5287
- setIsOpen(true);
5288
- }, [calculatePosition]);
5289
- const handleMouseLeave = useCallback(() => {
5290
- closeTimeoutRef.current = setTimeout(() => {
5291
- setIsOpen(false);
5292
- setIsHovered(false);
5293
- setHoveredItem(null);
5294
- }, 150);
5295
- }, []);
5296
- useEffect(() => {
5297
- return () => {
5298
- if (closeTimeoutRef.current) clearTimeout(closeTimeoutRef.current);
5299
- };
5300
- }, []);
5301
- const copyToClipboard = useCallback(async () => {
5302
- try {
5303
- await navigator.clipboard.writeText(address);
5304
- setIsCopied(true);
5305
- setTimeout(() => setIsCopied(false), 2e3);
5306
- } catch (err) {
5307
- console.error("Failed to copy address:", err);
5308
- }
5309
- }, [address]);
5310
- const triggerElement = asChild ? /* @__PURE__ */ jsx(Slot, {
5311
- "data-renown-state": "authenticated",
5312
- children
5313
- }) : /* @__PURE__ */ jsxs("button", {
5314
- type: "button",
5315
- style: {
5316
- ...styles.trigger,
5317
- ...isHovered ? styles.triggerHover : {},
5318
- ...style
5319
- },
5320
- "aria-label": "Open account menu",
5321
- "data-renown-state": "authenticated",
5322
- children: [
5323
- avatarUrl ? /* @__PURE__ */ jsx("img", {
5324
- src: avatarUrl,
5325
- alt: "Avatar",
5326
- style: styles.avatar
5327
- }) : /* @__PURE__ */ jsx("div", {
5328
- style: styles.avatarPlaceholder,
5329
- children: /* @__PURE__ */ jsx("span", {
5330
- style: styles.avatarInitial,
5331
- children: (displayName || "U")[0].toUpperCase()
5332
- })
5333
- }),
5334
- /* @__PURE__ */ jsx("span", {
5335
- style: styles.displayName,
5336
- children: displayName
5337
- }),
5338
- /* @__PURE__ */ jsx(ChevronDownIcon, {
5339
- size: 14,
5340
- style: {
5341
- ...styles.chevron,
5342
- ...isOpen ? styles.chevronOpen : {}
5343
- }
5344
- })
5345
- ]
5346
- });
5347
- return /* @__PURE__ */ jsxs("div", {
5348
- ref: wrapperRef,
5349
- style: styles.wrapper,
5350
- className,
5351
- onMouseEnter: handleMouseEnter,
5352
- onMouseLeave: handleMouseLeave,
5353
- children: [triggerElement, isOpen && /* @__PURE__ */ jsxs("div", {
5354
- style: {
5355
- ...styles.popoverBase,
5356
- ...showAbove ? { bottom: `calc(100% + ${POPOVER_GAP}px)` } : { top: `calc(100% + ${POPOVER_GAP}px)` }
5357
- },
5358
- children: [
5359
- /* @__PURE__ */ jsxs("div", {
5360
- style: styles.header,
5361
- children: [username && /* @__PURE__ */ jsx("div", {
5362
- style: styles.headerUsername,
5363
- children: username
5364
- }), address && /* @__PURE__ */ jsx("div", {
5365
- style: styles.addressRow,
5366
- children: /* @__PURE__ */ jsx("button", {
5367
- type: "button",
5368
- onClick: () => void copyToClipboard(),
5369
- style: styles.addressButton,
5370
- children: /* @__PURE__ */ jsxs("div", {
5371
- style: {
5372
- position: "relative",
5373
- display: "flex",
5374
- alignItems: "center",
5375
- gap: "4px",
5376
- width: "100%"
5377
- },
5378
- children: [/* @__PURE__ */ jsxs("div", {
5379
- style: {
5380
- ...styles.addressText,
5381
- opacity: isCopied ? 0 : 1
5382
- },
5383
- children: [/* @__PURE__ */ jsx("span", { children: truncateAddress(address) }), /* @__PURE__ */ jsx(CopyIcon, {
5384
- size: 12,
5385
- color: "#9ca3af"
5386
- })]
5387
- }), /* @__PURE__ */ jsx("div", {
5388
- style: {
5389
- ...styles.copiedText,
5390
- opacity: isCopied ? 1 : 0
5391
- },
5392
- children: "Copied!"
5393
- })]
5394
- })
5395
- })
5396
- })]
5397
- }),
5398
- /* @__PURE__ */ jsxs("div", {
5399
- style: styles.menuSection,
5400
- children: [profileId && /* @__PURE__ */ jsxs("button", {
5401
- type: "button",
5402
- onClick: () => openRenown(profileId),
5403
- onMouseEnter: () => setHoveredItem("profile"),
5404
- onMouseLeave: () => setHoveredItem(null),
5405
- style: {
5406
- ...styles.menuItem,
5407
- ...hoveredItem === "profile" ? styles.menuItemHover : {}
5408
- },
5409
- children: [/* @__PURE__ */ jsx(UserIcon, {
5410
- size: 14,
5411
- color: "#6b7280"
5412
- }), "View Profile"]
5413
- }), menuItems?.map((item) => /* @__PURE__ */ jsxs("button", {
5414
- type: "button",
5415
- onClick: item.onClick,
5416
- onMouseEnter: () => setHoveredItem(item.label),
5417
- onMouseLeave: () => setHoveredItem(null),
5418
- style: {
5419
- ...styles.menuItem,
5420
- ...hoveredItem === item.label ? styles.menuItemHover : {},
5421
- ...item.style
5422
- },
5423
- children: [item.icon, item.label]
5424
- }, item.label))]
5425
- }),
5426
- /* @__PURE__ */ jsx("hr", { style: styles.separator }),
5427
- /* @__PURE__ */ jsx("div", {
5428
- style: styles.menuSection,
5429
- children: /* @__PURE__ */ jsxs("button", {
5430
- type: "button",
5431
- onClick: onDisconnect,
5432
- onMouseEnter: () => setHoveredItem("disconnect"),
5433
- onMouseLeave: () => setHoveredItem(null),
5434
- style: {
5435
- ...styles.menuItem,
5436
- ...styles.disconnectItem,
5437
- ...hoveredItem === "disconnect" ? styles.menuItemHover : {}
5438
- },
5439
- children: [/* @__PURE__ */ jsx(DisconnectIcon, {
5440
- size: 14,
5441
- color: "#dc2626"
5442
- }), "Log out"]
5443
- })
5444
- })
5445
- ]
5446
- })]
5447
- });
5448
- }
5449
- //#endregion
5450
- //#region src/renown/components/RenownAuthButton.tsx
5451
- function RenownAuthButton({ className = "", darkMode, loginContent, userContent, loadingContent, children }) {
5452
- const auth = useRenownAuth();
5453
- if (children) return /* @__PURE__ */ jsx(Fragment, { children: children(auth) });
5454
- if (auth.status === "loading" || auth.status === "checking") {
5455
- if (loadingContent) return /* @__PURE__ */ jsx("div", {
5456
- className,
5457
- children: loadingContent
5458
- });
5459
- return /* @__PURE__ */ jsxs("div", {
5460
- className,
5461
- children: [/* @__PURE__ */ jsxs("div", {
5462
- style: {
5463
- display: "flex",
5464
- alignItems: "center",
5465
- gap: "8px",
5466
- padding: "6px 12px",
5467
- borderRadius: "8px",
5468
- border: "1px solid #e5e7eb",
5469
- animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"
5470
- },
5471
- children: [/* @__PURE__ */ jsx("div", { style: {
5472
- width: "28px",
5473
- height: "28px",
5474
- borderRadius: "50%",
5475
- backgroundColor: "#e5e7eb"
5476
- } }), /* @__PURE__ */ jsx("div", { style: {
5477
- width: "80px",
5478
- height: "14px",
5479
- borderRadius: "4px",
5480
- backgroundColor: "#e5e7eb"
5481
- } })]
5482
- }), /* @__PURE__ */ jsx("style", { children: `@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }` })]
5483
- });
5484
- }
5485
- if (auth.status === "authorized") {
5486
- if (userContent) return /* @__PURE__ */ jsx("div", {
5487
- className,
5488
- children: userContent
5489
- });
5490
- return /* @__PURE__ */ jsx("div", {
5491
- className,
5492
- children: /* @__PURE__ */ jsx(RenownUserButton, {})
5493
- });
5494
- }
5495
- if (loginContent) return /* @__PURE__ */ jsx("div", {
5496
- className,
5497
- children: loginContent
5498
- });
5499
- return /* @__PURE__ */ jsx("div", {
5500
- className,
5501
- children: /* @__PURE__ */ jsx(RenownLoginButton, { darkMode })
5502
- });
5503
- }
5504
- //#endregion
5505
- //#region src/renown/use-renown-init.ts
5506
- async function initRenown(appName, namespace, url) {
5507
- addRenownEventHandler();
5508
- setRenown(null);
5509
- const renown = await new RenownBuilder(appName, {
5510
- basename: namespace,
5511
- baseUrl: url
5512
- }).build();
5513
- setRenown(renown);
5514
- await login(void 0, renown);
5515
- return renown;
5516
- }
5517
- /**
5518
- * Hook that initializes the Renown SDK.
5519
- * Call once at the top of your app. Options are read only on first mount.
5520
- * Returns a promise that resolves with the Renown instance.
5521
- *
5522
- * @example
5523
- * ```tsx
5524
- * function App() {
5525
- * const renownPromise = useRenownInit({ appName: "my-app" });
5526
- * return <MyApp />;
5527
- * }
5528
- * ```
5529
- */
5530
- function useRenownInit({ appName, namespace, url }) {
5531
- const promiseRef = useRef(Promise.withResolvers());
5532
- const initRef = useRef(false);
5533
- if (typeof window === "undefined") {
5534
- promiseRef.current.reject(/* @__PURE__ */ new Error("window is undefined"));
5535
- return promiseRef.current.promise;
5536
- }
5537
- if (initRef.current) return promiseRef.current.promise;
5538
- initRef.current = true;
5539
- initRenown(appName, namespace, url).then(promiseRef.current.resolve).catch(promiseRef.current.reject);
5540
- return promiseRef.current.promise;
5541
- }
5542
- //#endregion
5543
- //#region src/renown/renown-init.tsx
5544
- /**
5545
- * Side-effect component that initializes the Renown SDK.
5546
- * Renders nothing — place it alongside your app tree.
5547
- *
5548
- * @example
5549
- * ```tsx
5550
- * function App() {
5551
- * return (
5552
- * <>
5553
- * <Renown appName="my-app" onError={console.error} />
5554
- * <MyApp />
5555
- * </>
5556
- * );
5557
- * }
5558
- * ```
5559
- */
5560
- function Renown({ onError, ...initOptions }) {
5561
- useRenownInit(initOptions).catch(onError ?? console.error);
5562
- return null;
5563
- }
5564
- //#endregion
5565
2778
  //#region src/storage/base-storage.ts
5566
2779
  var BaseStorage = class {
5567
2780
  [Symbol.iterator]() {
@@ -5622,6 +2835,6 @@ var BrowserLocalStorage = class extends BaseStorage {
5622
2835
  }
5623
2836
  };
5624
2837
  //#endregion
5625
- export { ActionTracker, AnalyticsProvider, BaseStorage, BrowserLocalStorage, COMMON_PACKAGE_ID, CREDENTIAL_SCHEMA_EIP712_TYPE, CREDENTIAL_SUBJECT_TYPE, CREDENTIAL_TYPES, ChannelScheme, ChevronDownIcon, ConflictError, CopyIcon, DEFAULT_DRIVE_EDITOR_ID, DOMAIN_TYPE, DisconnectIcon, DocumentCache, DocumentChangeType, DocumentIntegrityService, GqlRequestChannel, ISSUER_TYPE, InMemoryQueue, IntervalPollTimer, PropagationMode, REACTOR_SCHEMA, RENOWN_CHAIN_ID, RENOWN_NETWORK_ID, RENOWN_URL, ReactorBuilder, ReactorClientBuilder, RegistryClient, RelationalDbProcessor, RemoteClient, RemoteDocumentController, Renown, RenownAuthButton, RenownLoginButton, RenownLogo, RenownUserButton, SpinnerIcon, SyncOperationStatus, UserIcon, VERIFIABLE_CREDENTIAL_EIP712_TYPE, addAllowListEventHandler, addAllowedDocumentTypesEventHandler, addAnalyticsDatabaseNameEventHandler, addBasePathEventHandler, addCliVersionEventHandler, addDefaultDrivesUrlEventHandler, addDisabledEditorsEventHandler, addDocument, addDocumentCacheEventHandler, addDrive, addDrivesEventHandler, addDrivesPreserveStrategyEventHandler, addEnabledEditorsEventHandler, addFeaturesEventHandler, addFileUploadOperationsChunkSizeEventHandler, addFolder, addGaTrackingIdEventHandler, 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, analyticsEngineKey, analyticsOptionsKey, analyticsStoreKey, baseDocumentModels, baseDocumentModelsMap, buildDocumentSubgraphQuery, buildDocumentSubgraphUrl, callGlobalSetterForKey, clearGlobal, closePHModal, convertRemoteOperations, createAnalyticsStore, createClient, createProcessorQuery, createUrlWithPreservedParams, deleteDrive, deleteNode, dispatchActions, driveCollectionId, driveIdFromUrl, dropAllReactorStorage, exportDocument, exportFile, extractDriveIdFromPath, extractDriveIdFromSlug, extractDriveSlugFromPath, extractNodeIdFromPath, extractNodeIdFromSlug, extractNodeSlugFromPath, findUuid, getAnalyticsStore, getDocumentGraphqlQuery, getDriveIdBySlug, getDrives, getGlobal, getPackages, getPackagesByDocumentType, getPathWithoutBase, getRevisionFromDate, getSlugFromDriveUrl, getSwitchboardGatewayUrlFromDriveUrl, getSyncStatus, getSyncStatusSync, getUserPermissions, hideRevisionHistory, initConnectCrypto, initRenownCrypto, isDocumentTypeSupported, isExternalControlsEnabledEventFunctions, isFileNodeKind, isFolderNodeKind, loading, login, logout, makeDriveUrlComponent, makeNodeSlug, makePHEventFunctions, openRenown, parseDriveUrl, phAppConfigHooks, phAppConfigSetters, phDocumentEditorConfigHooks, phDocumentEditorConfigSetters, phGlobalConfigHooks, phGlobalConfigSetters, readPromiseState, refreshReactorData, refreshReactorDataClient, renameDrive, renameDriveNode, resolveUrlPathname, setAllowList, setAllowedDocumentTypes, setAnalyticsDatabaseName, setBasePath, setCliVersion, setDefaultDrivesUrl, setDefaultPHGlobalConfig, setDisabledEditors, setDocumentCache, setDriveAvailableOffline, setDriveSharingType, setDrives, setDrivesPreserveStrategy, setEnabledEditors, setFeatures, setFileUploadOperationsChunkSize, setGaTrackingId, setGlobal, 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, setPHAppConfig, setPHAppConfigByKey, setPHDocumentEditorConfig, setPHDocumentEditorConfigByKey, setPHGlobalConfig, setPHGlobalConfigByKey, setPHModal, setPHToast, setPackageDiscoveryService, setReactorClient, setReactorClientModule, setRenown, setRenownChainId, setRenownNetworkId, setRenownUrl, setRequiresHardRefresh, setRevisionHistoryVisible, setRouterBasename, setSelectedDrive, setSelectedNode, setSelectedTimelineItem, setSelectedTimelineRevision, setSentryDsn, setSentryEnv, setSentryRelease, setStudioMode, setVersion, setVersionCheckInterval, setVetraPackageManager, setWarnOutdatedApp, showCreateDocumentModal, showDeleteNodeModal, showPHModal, showRevisionHistory, sortNodesByName, truncateAllTables, useAddSeriesValue, useAddSeriesValues, useAllowList, useAllowedDocumentModelModules, useAllowedDocumentTypes, useAnalyticsDatabaseName, useAnalyticsEngine, useAnalyticsEngineAsync, useAnalyticsQuery, useAnalyticsSeries, useAnalyticsStore, useAnalyticsStoreAsync, useAnalyticsStoreOptions, useAnalyticsStoreQuery, useAppModuleById, useAppModules, useBasePath, useClearEmptyAnalyticsDimensions, useClearSeriesBySource, useCliVersion, useConnectionState, useConnectionStates, useCreateAnalyticsStore, useDatabase, useDefaultAppModule, useDefaultDrivesUrl, useDid, useDisabledEditors, useDispatch, useDocument, useDocumentById, useDocumentCache, useDocumentModelModuleById, useDocumentModelModules, useDocumentOfType, useDocumentOperations, useDocumentTimeline, useDocumentTypes, useDocumentTypesInSelectedDrive, useDocuments, useDocumentsByIds, useDocumentsInSelectedDrive, useDocumentsInSelectedFolder, useDriveById, useDrives, useDrivesPreserveStrategy, useEditorModuleById, useEditorModules, useEditorModulesForDocumentType, useEnabledEditors, useFallbackEditorModule, useFeatures, useFileNodesInSelectedDrive, useFileNodesInSelectedFolder, useFileUploadOperationsChunkSize, useFolderById, useFolderNodesInSelectedDrive, useFolderNodesInSelectedFolder, useGaTrackingId, useGetDimensions, useGetDocument, useGetDocumentAsync, useGetDocuments, useGetSwitchboardLink, 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, useMatchingSeries, useModelRegistry, useNodeActions, useNodeById, useNodeParentFolderById, useNodePathById, useNodesInSelectedDrive, useNodesInSelectedDriveOrFolder, useNodesInSelectedFolder, useOnDropFile, usePGlite, usePHAppConfigByKey, usePHDocumentEditorConfigByKey, usePHGlobalConfigByKey, usePHModal, usePHToast, usePackageDiscoveryService, useParentFolderForSelectedNode, useQuerySources, 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, useTimelineItems, useUser, useUserPermissions, useVersion, useVersionCheckInterval, useVetraPackageManager, useVetraPackages, useWarnOutdatedApp, validateDocument };
2838
+ export { ActionTracker, BaseStorage, BrowserLocalStorage, COMMON_PACKAGE_ID, CREDENTIAL_SCHEMA_EIP712_TYPE, CREDENTIAL_SUBJECT_TYPE, CREDENTIAL_TYPES, ChannelScheme, ChevronDownIcon, ConflictError, CopyIcon, DEFAULT_DRIVE_EDITOR_ID, DOMAIN_TYPE, DisconnectIcon, DocumentCache, DocumentChangeType, DocumentIntegrityService, GqlRequestChannel, ISSUER_TYPE, InMemoryQueue, IntervalPollTimer, PropagationMode, REACTOR_SCHEMA, RENOWN_CHAIN_ID, RENOWN_NETWORK_ID, RENOWN_URL, ReactorBuilder, ReactorClientBuilder, RegistryClient, RelationalDbProcessor, RemoteClient, RemoteDocumentController, Renown, RenownAuthButton, RenownLoginButton, RenownLogo, RenownUserButton, SpinnerIcon, SyncOperationStatus, UserIcon, VERIFIABLE_CREDENTIAL_EIP712_TYPE, addAllowListEventHandler, addAllowedDocumentTypesEventHandler, addAnalyticsDatabaseNameEventHandler, addBasePathEventHandler, addCliVersionEventHandler, addDefaultDrivesUrlEventHandler, addDisabledEditorsEventHandler, addDocument, addDocumentCacheEventHandler, addDrive, addDrivesEventHandler, addDrivesPreserveStrategyEventHandler, addEnabledEditorsEventHandler, addFeaturesEventHandler, addFileUploadOperationsChunkSizeEventHandler, addFolder, addGaTrackingIdEventHandler, 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, callGlobalSetterForKey, clearGlobal, closePHModal, convertRemoteOperations, createAnalyticsStore, createClient, createProcessorQuery, createUrlWithPreservedParams, deleteDrive, deleteNode, dispatchActions, driveCollectionId, driveIdFromUrl, dropAllReactorStorage, exportDocument, exportFile, extractDriveIdFromPath, extractDriveIdFromSlug, extractDriveSlugFromPath, extractNodeIdFromPath, extractNodeIdFromSlug, extractNodeSlugFromPath, findUuid, getAnalyticsStore, getDocumentGraphqlQuery, getDriveIdBySlug, getDrives, getGlobal, getPackages, getPackagesByDocumentType, getPathWithoutBase, getRevisionFromDate, getSlugFromDriveUrl, getSwitchboardGatewayUrlFromDriveUrl, getSyncStatus, getSyncStatusSync, getUserPermissions, hideRevisionHistory, initConnectCrypto, initRenownCrypto, isDocumentTypeSupported, isExternalControlsEnabledEventFunctions, isFileNodeKind, isFolderNodeKind, loading, login, logout, makeDriveUrlComponent, makeNodeSlug, makePHEventFunctions, openRenown, parseDriveUrl, phAppConfigHooks, phAppConfigSetters, phDocumentEditorConfigHooks, phDocumentEditorConfigSetters, phGlobalConfigHooks, phGlobalConfigSetters, readPromiseState, refreshReactorData, refreshReactorDataClient, renameDrive, renameDriveNode, resolveUrlPathname, setAllowList, setAllowedDocumentTypes, setAnalyticsDatabaseName, setBasePath, setCliVersion, setDefaultDrivesUrl, setDefaultPHGlobalConfig, setDisabledEditors, setDocumentCache, setDriveAvailableOffline, setDriveSharingType, setDrives, setDrivesPreserveStrategy, setEnabledEditors, setFeatures, setFileUploadOperationsChunkSize, setGaTrackingId, setGlobal, 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, setPHAppConfig, setPHAppConfigByKey, setPHDocumentEditorConfig, setPHDocumentEditorConfigByKey, setPHGlobalConfig, setPHGlobalConfigByKey, setPHModal, setPHToast, setPackageDiscoveryService, setReactorClient, setReactorClientModule, setRenown, setRenownChainId, setRenownNetworkId, setRenownUrl, setRequiresHardRefresh, setRevisionHistoryVisible, setRouterBasename, setSelectedDrive, setSelectedNode, setSelectedTimelineItem, setSelectedTimelineRevision, setSentryDsn, setSentryEnv, setSentryRelease, setStudioMode, setVersion, setVersionCheckInterval, setVetraPackageManager, setWarnOutdatedApp, showCreateDocumentModal, showDeleteNodeModal, showPHModal, showRevisionHistory, sortNodesByName, truncateAllTables, useAllowList, useAllowedDocumentModelModules, useAllowedDocumentTypes, useAnalyticsDatabaseName, useAppModuleById, useAppModules, useBasePath, useCliVersion, useConnectionState, useConnectionStates, useDatabase, useDefaultAppModule, useDefaultDrivesUrl, useDid, useDisabledEditors, useDispatch, useDocument, useDocumentById, useDocumentCache, useDocumentModelModuleById, useDocumentModelModules, useDocumentOfType, useDocumentOperations, useDocumentTypes, useDocumentTypesInSelectedDrive, useDocuments, useDocumentsByIds, useDocumentsInSelectedDrive, useDocumentsInSelectedFolder, useDriveById, useDrives, useDrivesPreserveStrategy, useEditorModuleById, useEditorModules, useEditorModulesForDocumentType, useEnabledEditors, useFallbackEditorModule, useFeatures, useFileNodesInSelectedDrive, useFileNodesInSelectedFolder, useFileUploadOperationsChunkSize, useFolderById, useFolderNodesInSelectedDrive, useFolderNodesInSelectedFolder, useGaTrackingId, useGetDocument, useGetDocumentAsync, useGetDocuments, useGetSwitchboardLink, 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, useUser, useUserPermissions, useVersion, useVersionCheckInterval, useVetraPackageManager, useVetraPackages, useWarnOutdatedApp, validateDocument };
5626
2839
 
5627
2840
  //# sourceMappingURL=index.js.map