@powerhousedao/reactor-browser 6.0.0-dev.84 → 6.0.0-dev.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/src/analytics.js +29 -5
  2. package/dist/src/connect.js +65 -22
  3. package/dist/src/hooks/index.d.ts +5 -2
  4. package/dist/src/hooks/index.d.ts.map +1 -1
  5. package/dist/src/hooks/loading.d.ts +2 -0
  6. package/dist/src/hooks/loading.d.ts.map +1 -1
  7. package/dist/src/hooks/make-ph-event-functions.d.ts +1 -1
  8. package/dist/src/hooks/make-ph-event-functions.d.ts.map +1 -1
  9. package/dist/src/hooks/renown.d.ts +7 -9
  10. package/dist/src/hooks/renown.d.ts.map +1 -1
  11. package/dist/src/hooks/vetra-packages.d.ts +3 -0
  12. package/dist/src/hooks/vetra-packages.d.ts.map +1 -1
  13. package/dist/src/index.js +951 -661
  14. package/dist/src/package-manager.d.ts +21 -2
  15. package/dist/src/package-manager.d.ts.map +1 -1
  16. package/dist/src/re-exports.d.ts +1 -1
  17. package/dist/src/re-exports.d.ts.map +1 -1
  18. package/dist/src/registry/client.d.ts +1 -0
  19. package/dist/src/registry/client.d.ts.map +1 -1
  20. package/dist/src/remote-controller/types.d.ts +2 -2
  21. package/dist/src/remote-controller/types.d.ts.map +1 -1
  22. package/dist/src/renown/components/RenownAuthButton.d.ts +8 -14
  23. package/dist/src/renown/components/RenownAuthButton.d.ts.map +1 -1
  24. package/dist/src/renown/components/RenownLoginButton.d.ts +3 -7
  25. package/dist/src/renown/components/RenownLoginButton.d.ts.map +1 -1
  26. package/dist/src/renown/components/RenownUserButton.d.ts +10 -8
  27. package/dist/src/renown/components/RenownUserButton.d.ts.map +1 -1
  28. package/dist/src/renown/components/icons.d.ts +1 -1
  29. package/dist/src/renown/components/icons.d.ts.map +1 -1
  30. package/dist/src/renown/components/index.d.ts +3 -3
  31. package/dist/src/renown/components/index.d.ts.map +1 -1
  32. package/dist/src/renown/components/slot.d.ts +8 -0
  33. package/dist/src/renown/components/slot.d.ts.map +1 -0
  34. package/dist/src/renown/index.d.ts +3 -1
  35. package/dist/src/renown/index.d.ts.map +1 -1
  36. package/dist/src/renown/renown-init.d.ts +22 -0
  37. package/dist/src/renown/renown-init.d.ts.map +1 -0
  38. package/dist/src/renown/use-renown-auth.d.ts +17 -0
  39. package/dist/src/renown/use-renown-auth.d.ts.map +1 -0
  40. package/dist/src/renown/use-renown-init.d.ts +25 -0
  41. package/dist/src/renown/use-renown-init.d.ts.map +1 -0
  42. package/dist/src/renown/utils.d.ts.map +1 -1
  43. package/dist/src/types/global.d.ts +2 -1
  44. package/dist/src/types/global.d.ts.map +1 -1
  45. package/dist/src/types/vetra.d.ts +1 -1
  46. package/dist/src/types/vetra.d.ts.map +1 -1
  47. package/dist/test/renown/script.node.test.d.ts +2 -0
  48. package/dist/test/renown/script.node.test.d.ts.map +1 -0
  49. package/dist/tsconfig.tsbuildinfo +1 -1
  50. package/dist/vitest.config.d.ts.map +1 -1
  51. package/package.json +7 -7
  52. package/dist/src/renown/components/image-data.d.ts +0 -3
  53. package/dist/src/renown/components/image-data.d.ts.map +0 -1
  54. package/dist/src/renown/provider.d.ts +0 -9
  55. package/dist/src/renown/provider.d.ts.map +0 -1
  56. package/dist/test/renown/script.test.d.ts +0 -2
  57. package/dist/test/renown/script.test.d.ts.map +0 -1
package/dist/src/index.js CHANGED
@@ -8495,6 +8495,12 @@ function createClient(urlOrGQLClient, middleware) {
8495
8495
  const client = typeof urlOrGQLClient === "string" ? new GraphQLClient(urlOrGQLClient) : urlOrGQLClient;
8496
8496
  return getSdk(client, middleware);
8497
8497
  }
8498
+ // src/renown/use-renown-auth.ts
8499
+ import { useCallback } from "react";
8500
+
8501
+ // src/hooks/renown.ts
8502
+ import { useEffect, useState, useSyncExternalStore as useSyncExternalStore2 } from "react";
8503
+
8498
8504
  // ../../node_modules/.pnpm/change-case@5.4.4/node_modules/change-case/dist/index.js
8499
8505
  var SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
8500
8506
  var SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
@@ -8571,42 +8577,66 @@ function splitPrefixSuffix(input, options = {}) {
8571
8577
 
8572
8578
  // src/hooks/make-ph-event-functions.ts
8573
8579
  import { useSyncExternalStore } from "react";
8580
+ var isServer = typeof window === "undefined";
8574
8581
  function makePHEventFunctions(key) {
8575
8582
  const setEventName = `ph:set${capitalCase(key)}`;
8576
8583
  const updateEventName = `ph:${key}Updated`;
8577
8584
  function setValue(value) {
8585
+ if (isServer) {
8586
+ return;
8587
+ }
8578
8588
  const event = new CustomEvent(setEventName, {
8579
8589
  detail: { [key]: value }
8580
8590
  });
8581
8591
  window.dispatchEvent(event);
8582
8592
  }
8583
8593
  function dispatchUpdatedEvent() {
8594
+ if (isServer) {
8595
+ return;
8596
+ }
8584
8597
  const event = new CustomEvent(updateEventName);
8585
8598
  window.dispatchEvent(event);
8586
8599
  }
8587
8600
  function handleSetValueEvent(event) {
8601
+ if (isServer) {
8602
+ return;
8603
+ }
8588
8604
  const value = event.detail[key];
8589
- if (!window.ph)
8590
- throw new Error("ph global store is not defined");
8605
+ if (!window.ph) {
8606
+ window.ph = {};
8607
+ }
8591
8608
  window.ph[key] = value;
8592
8609
  dispatchUpdatedEvent();
8593
8610
  }
8594
8611
  function addEventHandler() {
8612
+ if (isServer) {
8613
+ return;
8614
+ }
8595
8615
  window.addEventListener(setEventName, handleSetValueEvent);
8596
8616
  }
8597
8617
  function subscribeToValue(onStoreChange) {
8618
+ if (isServer)
8619
+ return () => {};
8598
8620
  window.addEventListener(updateEventName, onStoreChange);
8599
8621
  return () => {
8600
8622
  window.removeEventListener(updateEventName, onStoreChange);
8601
8623
  };
8602
8624
  }
8603
8625
  function getSnapshot() {
8604
- if (!window.ph)
8605
- throw new Error("ph global store is not defined");
8626
+ if (isServer) {
8627
+ return;
8628
+ }
8629
+ if (!window.ph) {
8630
+ console.warn(`ph global store is not initialized. Did you call set${capitalCase(key)}?`);
8631
+ return;
8632
+ }
8606
8633
  return window.ph[key];
8607
8634
  }
8635
+ function getServerSnapshot() {
8636
+ return;
8637
+ }
8608
8638
  function useValue() {
8609
- return useSyncExternalStore(subscribeToValue, getSnapshot);
8639
+ return useSyncExternalStore(subscribeToValue, getSnapshot, getServerSnapshot);
8610
8640
  }
8611
8641
  return {
8612
8642
  useValue,
@@ -8615,6 +8645,199 @@ function makePHEventFunctions(key) {
8615
8645
  };
8616
8646
  }
8617
8647
 
8648
+ // src/hooks/loading.ts
8649
+ var {
8650
+ useValue: useLoading,
8651
+ setValue: setLoading,
8652
+ addEventHandler: addLoadingEventHandler
8653
+ } = makePHEventFunctions("loading");
8654
+ var loading = null;
8655
+
8656
+ // src/hooks/renown.ts
8657
+ var renownEventFunctions = makePHEventFunctions("renown");
8658
+ var addRenownEventHandler = renownEventFunctions.addEventHandler;
8659
+ var useRenown = renownEventFunctions.useValue;
8660
+ var setRenown = renownEventFunctions.setValue;
8661
+ function useDid() {
8662
+ const renown = useRenown();
8663
+ return renown?.did;
8664
+ }
8665
+ function useUser() {
8666
+ const renown = useRenown();
8667
+ const [user, setUser] = useState(renown?.user);
8668
+ useEffect(() => {
8669
+ setUser(renown?.user);
8670
+ if (!renown)
8671
+ return;
8672
+ return renown.on("user", setUser);
8673
+ }, [renown]);
8674
+ return user;
8675
+ }
8676
+ function useLoginStatus() {
8677
+ const renown = useRenown();
8678
+ return useSyncExternalStore2((cb) => {
8679
+ if (!renown) {
8680
+ return () => {};
8681
+ }
8682
+ return renown.on("status", cb);
8683
+ }, () => renown === loading ? "loading" : renown?.status, () => {
8684
+ return;
8685
+ });
8686
+ }
8687
+
8688
+ // src/renown/utils.ts
8689
+ import { logger as logger5 } from "document-drive";
8690
+
8691
+ // src/renown/constants.ts
8692
+ var RENOWN_URL = "https://www.renown.id";
8693
+ var RENOWN_NETWORK_ID = "eip155";
8694
+ var RENOWN_CHAIN_ID = "1";
8695
+ var DOMAIN_TYPE = [
8696
+ { name: "name", type: "string" },
8697
+ { name: "version", type: "string" },
8698
+ { name: "chainId", type: "uint256" },
8699
+ { name: "verifyingContract", type: "address" }
8700
+ ];
8701
+ var VERIFIABLE_CREDENTIAL_EIP712_TYPE = [
8702
+ { name: "@context", type: "string[]" },
8703
+ { name: "type", type: "string[]" },
8704
+ { name: "id", type: "string" },
8705
+ { name: "issuer", type: "Issuer" },
8706
+ { name: "credentialSubject", type: "CredentialSubject" },
8707
+ { name: "credentialSchema", type: "CredentialSchema" },
8708
+ { name: "issuanceDate", type: "string" },
8709
+ { name: "expirationDate", type: "string" }
8710
+ ];
8711
+ var CREDENTIAL_SCHEMA_EIP712_TYPE = [
8712
+ { name: "id", type: "string" },
8713
+ { name: "type", type: "string" }
8714
+ ];
8715
+ var CREDENTIAL_SUBJECT_TYPE = [
8716
+ { name: "app", type: "string" },
8717
+ { name: "id", type: "string" },
8718
+ { name: "name", type: "string" }
8719
+ ];
8720
+ var ISSUER_TYPE = [
8721
+ { name: "id", type: "string" },
8722
+ { name: "ethereumAddress", type: "string" }
8723
+ ];
8724
+ var CREDENTIAL_TYPES = {
8725
+ EIP712Domain: DOMAIN_TYPE,
8726
+ VerifiableCredential: VERIFIABLE_CREDENTIAL_EIP712_TYPE,
8727
+ CredentialSchema: CREDENTIAL_SCHEMA_EIP712_TYPE,
8728
+ CredentialSubject: CREDENTIAL_SUBJECT_TYPE,
8729
+ Issuer: ISSUER_TYPE
8730
+ };
8731
+
8732
+ // src/renown/utils.ts
8733
+ function openRenown(documentId) {
8734
+ const renown = window.ph?.renown;
8735
+ let renownUrl = renown?.baseUrl;
8736
+ if (!renownUrl) {
8737
+ logger5.warn("Renown instance not found, falling back to: ", RENOWN_URL);
8738
+ renownUrl = RENOWN_URL;
8739
+ }
8740
+ if (documentId) {
8741
+ window.open(`${renownUrl}/profile/${documentId}`, "_blank")?.focus();
8742
+ return;
8743
+ }
8744
+ const url = new URL(renownUrl);
8745
+ url.searchParams.set("app", renown?.did ?? "");
8746
+ url.searchParams.set("connect", renown?.did ?? "");
8747
+ url.searchParams.set("network", RENOWN_NETWORK_ID);
8748
+ url.searchParams.set("chain", RENOWN_CHAIN_ID);
8749
+ const returnUrl = new URL(window.location.pathname, window.location.origin);
8750
+ url.searchParams.set("returnUrl", returnUrl.toJSON());
8751
+ window.open(url, "_self")?.focus();
8752
+ }
8753
+ function consumeDidFromUrl() {
8754
+ if (typeof window === "undefined")
8755
+ return;
8756
+ const urlParams = new URLSearchParams(window.location.search);
8757
+ const userParam = urlParams.get("user");
8758
+ if (!userParam)
8759
+ return;
8760
+ const userDid = decodeURIComponent(userParam);
8761
+ const cleanUrl = new URL(window.location.href);
8762
+ cleanUrl.searchParams.delete("user");
8763
+ window.history.replaceState({}, "", cleanUrl.toString());
8764
+ return userDid;
8765
+ }
8766
+ async function login(userDid, renown) {
8767
+ if (!renown) {
8768
+ return;
8769
+ }
8770
+ const did = userDid ?? consumeDidFromUrl();
8771
+ try {
8772
+ const user = renown.user;
8773
+ if (user?.did && (user.did === did || !did)) {
8774
+ return user;
8775
+ }
8776
+ if (!did) {
8777
+ return;
8778
+ }
8779
+ return await renown.login(did);
8780
+ } catch (error) {
8781
+ logger5.error(error instanceof Error ? error.message : JSON.stringify(error));
8782
+ }
8783
+ }
8784
+ async function logout() {
8785
+ const renown = window.ph?.renown;
8786
+ await renown?.logout();
8787
+ const url = new URL(window.location.href);
8788
+ if (url.searchParams.has("user")) {
8789
+ url.searchParams.delete("user");
8790
+ window.history.replaceState(null, "", url.toString());
8791
+ }
8792
+ }
8793
+
8794
+ // src/renown/use-renown-auth.ts
8795
+ function truncateAddress(address) {
8796
+ if (address.length <= 13)
8797
+ return address;
8798
+ return `${address.slice(0, 7)}...${address.slice(-5)}`;
8799
+ }
8800
+ function toRenownAuthStatus(loginStatus, user) {
8801
+ if (loginStatus === "authorized") {
8802
+ return user ? "authorized" : "checking";
8803
+ }
8804
+ return loginStatus;
8805
+ }
8806
+ function useRenownAuth() {
8807
+ const user = useUser();
8808
+ const loginStatus = useLoginStatus();
8809
+ const status = toRenownAuthStatus(loginStatus, user);
8810
+ const address = user?.address;
8811
+ const ensName = user?.ens?.name;
8812
+ const avatarUrl = user?.profile?.userImage ?? user?.ens?.avatarUrl;
8813
+ const profileId = user?.profile?.documentId;
8814
+ const displayName = ensName ?? user?.profile?.username ?? undefined;
8815
+ const displayAddress = address ? truncateAddress(address) : undefined;
8816
+ const login2 = useCallback(() => {
8817
+ openRenown();
8818
+ }, []);
8819
+ const logout2 = useCallback(async () => {
8820
+ await logout();
8821
+ }, []);
8822
+ const openProfile = useCallback(() => {
8823
+ if (profileId) {
8824
+ openRenown(profileId);
8825
+ }
8826
+ }, [profileId]);
8827
+ return {
8828
+ status,
8829
+ user,
8830
+ address,
8831
+ ensName,
8832
+ avatarUrl,
8833
+ profileId,
8834
+ displayName,
8835
+ displayAddress,
8836
+ login: login2,
8837
+ logout: logout2,
8838
+ openProfile
8839
+ };
8840
+ }
8618
8841
  // src/hooks/config/editor.ts
8619
8842
  var isExternalControlsEnabledEventFunctions = makePHEventFunctions("isExternalControlsEnabled");
8620
8843
  var setIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.setValue;
@@ -8648,12 +8871,12 @@ var phDocumentEditorConfigHooks = {
8648
8871
 
8649
8872
  // src/hooks/vetra-packages.ts
8650
8873
  import { DuplicateModuleError } from "@powerhousedao/reactor";
8651
- import { useSyncExternalStore as useSyncExternalStore2 } from "react";
8874
+ import { useSyncExternalStore as useSyncExternalStore3 } from "react";
8652
8875
  var vetraPackageManagerFunctions = makePHEventFunctions("vetraPackageManager");
8653
8876
  var useVetraPackageManager = vetraPackageManagerFunctions.useValue;
8654
8877
  var useVetraPackages = () => {
8655
8878
  const packageManager = useVetraPackageManager();
8656
- return useSyncExternalStore2((cb) => packageManager ? packageManager.subscribe(cb) : () => {}, () => packageManager?.packages ?? []);
8879
+ return useSyncExternalStore3((cb) => packageManager ? packageManager.subscribe(cb) : () => {}, () => packageManager?.packages ?? []);
8657
8880
  };
8658
8881
  var addVetraPackageManagerEventHandler = vetraPackageManagerFunctions.addEventHandler;
8659
8882
  function setVetraPackageManager(packageManager) {
@@ -8663,6 +8886,17 @@ function setVetraPackageManager(packageManager) {
8663
8886
  updateReactorClientDocumentModels(packages);
8664
8887
  });
8665
8888
  }
8889
+ var EMPTY_PENDING = [];
8890
+ var EMPTY_DISMISSED = [];
8891
+ var NOOP_UNSUBSCRIBE = () => {};
8892
+ function usePendingInstallations() {
8893
+ const pm = useVetraPackageManager();
8894
+ return useSyncExternalStore3((cb) => pm ? pm.subscribePendingChanges(cb) : NOOP_UNSUBSCRIBE, () => pm?.getPendingInstallations() ?? EMPTY_PENDING);
8895
+ }
8896
+ function useDismissedPackages() {
8897
+ const pm = useVetraPackageManager();
8898
+ return useSyncExternalStore3((cb) => pm ? pm.subscribePendingChanges(cb) : NOOP_UNSUBSCRIBE, () => pm?.getDismissedPackages() ?? EMPTY_DISMISSED);
8899
+ }
8666
8900
  function updateReactorClientDocumentModels(packages) {
8667
8901
  const documentModelModules = packages.flatMap((pkg) => pkg.modules.documentModelModules).filter((module) => module !== undefined);
8668
8902
  const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
@@ -8698,74 +8932,6 @@ function useAllowedDocumentModelModules() {
8698
8932
  return documentModelModules;
8699
8933
  return documentModelModules?.filter((module) => allowedDocumentTypes.includes(module.documentModel.global.id));
8700
8934
  }
8701
- // src/hooks/connection-state.ts
8702
- import { useEffect, useRef, useState } from "react";
8703
-
8704
- // src/hooks/reactor.ts
8705
- var reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
8706
- var reactorClientEventFunctions = makePHEventFunctions("reactorClient");
8707
- var useReactorClientModule = reactorClientModuleEventFunctions.useValue;
8708
- var setReactorClientModule = reactorClientModuleEventFunctions.setValue;
8709
- var addReactorClientModuleEventHandler = reactorClientModuleEventFunctions.addEventHandler;
8710
- var useReactorClient = reactorClientEventFunctions.useValue;
8711
- var setReactorClient = reactorClientEventFunctions.setValue;
8712
- var addReactorClientEventHandler = reactorClientEventFunctions.addEventHandler;
8713
- var useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager;
8714
- var useSyncList = () => {
8715
- const sync = useSync();
8716
- return sync?.list() ?? [];
8717
- };
8718
- var useModelRegistry = () => useReactorClientModule()?.reactorModule?.documentModelRegistry;
8719
- var useDatabase = () => useReactorClientModule()?.reactorModule?.database;
8720
- var usePGlite = () => useReactorClientModule()?.pg;
8721
-
8722
- // src/hooks/connection-state.ts
8723
- function useConnectionStates() {
8724
- const syncManager = useSync();
8725
- const [states, setStates] = useState(() => buildSnapshot(syncManager));
8726
- const unsubscribesRef = useRef([]);
8727
- useEffect(() => {
8728
- if (!syncManager)
8729
- return;
8730
- function subscribe() {
8731
- for (const unsub of unsubscribesRef.current) {
8732
- unsub();
8733
- }
8734
- unsubscribesRef.current = [];
8735
- const remotes = syncManager.list();
8736
- for (const remote of remotes) {
8737
- const unsub = remote.channel.onConnectionStateChange(() => {
8738
- setStates(buildSnapshot(syncManager));
8739
- });
8740
- unsubscribesRef.current.push(unsub);
8741
- }
8742
- setStates(buildSnapshot(syncManager));
8743
- }
8744
- subscribe();
8745
- const interval = setInterval(subscribe, 5000);
8746
- return () => {
8747
- clearInterval(interval);
8748
- for (const unsub of unsubscribesRef.current) {
8749
- unsub();
8750
- }
8751
- unsubscribesRef.current = [];
8752
- };
8753
- }, [syncManager]);
8754
- return states;
8755
- }
8756
- function useConnectionState(remoteName) {
8757
- const states = useConnectionStates();
8758
- return states.get(remoteName);
8759
- }
8760
- function buildSnapshot(syncManager) {
8761
- const map = new Map;
8762
- if (!syncManager)
8763
- return map;
8764
- for (const remote of syncManager.list()) {
8765
- map.set(remote.name, remote.channel.getConnectionState());
8766
- }
8767
- return map;
8768
- }
8769
8935
  // src/utils/nodes.ts
8770
8936
  function sortNodesByName(nodes) {
8771
8937
  return nodes.toSorted((a, b) => a.name.localeCompare(b.name));
@@ -8782,16 +8948,16 @@ function isFolderNodeKind(node) {
8782
8948
  }
8783
8949
 
8784
8950
  // src/hooks/dispatch.ts
8785
- import { logger as logger5 } from "document-drive";
8951
+ import { logger as logger6 } from "document-drive";
8786
8952
  function useDispatch(document2) {
8787
8953
  function dispatch(actionOrActions, onErrors, onSuccess) {
8788
- dispatchActions(actionOrActions, document2, onErrors, onSuccess).catch(logger5.error);
8954
+ dispatchActions(actionOrActions, document2, onErrors, onSuccess).catch(logger6.error);
8789
8955
  }
8790
8956
  return [document2, dispatch];
8791
8957
  }
8792
8958
 
8793
8959
  // src/hooks/document-cache.ts
8794
- import { use, useCallback as useCallback2, useSyncExternalStore as useSyncExternalStore3 } from "react";
8960
+ import { use, useCallback as useCallback2, useSyncExternalStore as useSyncExternalStore4 } from "react";
8795
8961
  var documentEventFunctions = makePHEventFunctions("documentCache");
8796
8962
  var useDocumentCache = documentEventFunctions.useValue;
8797
8963
  var setDocumentCache = documentEventFunctions.setValue;
@@ -8824,12 +8990,12 @@ function getDocumentQueryState(promise) {
8824
8990
  }
8825
8991
  function useDocument(id) {
8826
8992
  const documentCache = useDocumentCache();
8827
- const document2 = useSyncExternalStore3((cb) => id && documentCache ? documentCache.subscribe(id, cb) : () => {}, () => id ? documentCache?.get(id) : undefined);
8993
+ const document2 = useSyncExternalStore4((cb) => id && documentCache ? documentCache.subscribe(id, cb) : () => {}, () => id ? documentCache?.get(id) : undefined);
8828
8994
  return document2 ? use(document2) : undefined;
8829
8995
  }
8830
8996
  function useDocuments(ids) {
8831
8997
  const documentCache = useDocumentCache();
8832
- const documents = useSyncExternalStore3((cb) => ids?.length && documentCache ? documentCache.subscribe(ids, cb) : () => {}, () => ids?.length && documentCache ? documentCache.getBatch(ids) : undefined);
8998
+ const documents = useSyncExternalStore4((cb) => ids?.length && documentCache ? documentCache.subscribe(ids, cb) : () => {}, () => ids?.length && documentCache ? documentCache.getBatch(ids) : undefined);
8833
8999
  return documents ? use(documents) : [];
8834
9000
  }
8835
9001
  function useGetDocument() {
@@ -10303,39 +10469,107 @@ function usePHDocumentEditorConfigByKey(key) {
10303
10469
  const useValueHook = phDocumentEditorConfigHooks[key];
10304
10470
  return useValueHook();
10305
10471
  }
10306
- // src/hooks/document-of-type.ts
10307
- import {
10308
- DocumentModelNotFoundError,
10309
- DocumentNotFoundError
10310
- } from "document-drive";
10311
- function useDocumentOfType(documentId, documentType) {
10312
- const [document2, dispatch] = useDocumentById(documentId);
10313
- const documentModelModule = useDocumentModelModuleById(documentType);
10314
- if (!documentId || !documentType)
10315
- return [];
10316
- if (!document2) {
10317
- throw new DocumentNotFoundError(documentId);
10318
- }
10319
- if (!documentModelModule) {
10320
- throw new DocumentModelNotFoundError(documentType);
10321
- }
10322
- if (document2.header.documentType !== documentType) {
10323
- throw new DocumentTypeMismatchError(documentId, documentType, document2.header.documentType);
10324
- }
10325
- return [document2, dispatch];
10472
+ // src/hooks/connection-state.ts
10473
+ import { useEffect as useEffect3, useRef, useState as useState3 } from "react";
10474
+
10475
+ // src/hooks/reactor.ts
10476
+ var reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
10477
+ var reactorClientEventFunctions = makePHEventFunctions("reactorClient");
10478
+ var useReactorClientModule = reactorClientModuleEventFunctions.useValue;
10479
+ var setReactorClientModule = reactorClientModuleEventFunctions.setValue;
10480
+ var addReactorClientModuleEventHandler = reactorClientModuleEventFunctions.addEventHandler;
10481
+ var useReactorClient = reactorClientEventFunctions.useValue;
10482
+ var setReactorClient = reactorClientEventFunctions.setValue;
10483
+ var addReactorClientEventHandler = reactorClientEventFunctions.addEventHandler;
10484
+ var useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager;
10485
+ var useSyncList = () => {
10486
+ const sync = useSync();
10487
+ return sync?.list() ?? [];
10488
+ };
10489
+ var useModelRegistry = () => useReactorClientModule()?.reactorModule?.documentModelRegistry;
10490
+ var useDatabase = () => useReactorClientModule()?.reactorModule?.database;
10491
+ var usePGlite = () => useReactorClientModule()?.pg;
10492
+
10493
+ // src/hooks/connection-state.ts
10494
+ function useConnectionStates() {
10495
+ const syncManager = useSync();
10496
+ const [states, setStates] = useState3(() => buildSnapshot(syncManager));
10497
+ const unsubscribesRef = useRef([]);
10498
+ useEffect3(() => {
10499
+ if (!syncManager)
10500
+ return;
10501
+ function subscribe() {
10502
+ for (const unsub of unsubscribesRef.current) {
10503
+ unsub();
10504
+ }
10505
+ unsubscribesRef.current = [];
10506
+ const remotes = syncManager.list();
10507
+ for (const remote of remotes) {
10508
+ const unsub = remote.channel.onConnectionStateChange(() => {
10509
+ setStates(buildSnapshot(syncManager));
10510
+ });
10511
+ unsubscribesRef.current.push(unsub);
10512
+ }
10513
+ setStates(buildSnapshot(syncManager));
10514
+ }
10515
+ subscribe();
10516
+ const interval = setInterval(subscribe, 5000);
10517
+ return () => {
10518
+ clearInterval(interval);
10519
+ for (const unsub of unsubscribesRef.current) {
10520
+ unsub();
10521
+ }
10522
+ unsubscribesRef.current = [];
10523
+ };
10524
+ }, [syncManager]);
10525
+ return states;
10526
+ }
10527
+ function useConnectionState(remoteName) {
10528
+ const states = useConnectionStates();
10529
+ return states.get(remoteName);
10530
+ }
10531
+ function buildSnapshot(syncManager) {
10532
+ const map = new Map;
10533
+ if (!syncManager)
10534
+ return map;
10535
+ for (const remote of syncManager.list()) {
10536
+ map.set(remote.name, remote.channel.getConnectionState());
10537
+ }
10538
+ return map;
10539
+ }
10540
+ // src/hooks/document-of-type.ts
10541
+ import {
10542
+ DocumentModelNotFoundError,
10543
+ DocumentNotFoundError
10544
+ } from "document-drive";
10545
+ function useDocumentOfType(documentId, documentType) {
10546
+ const [document2, dispatch] = useDocumentById(documentId);
10547
+ const documentModelModule = useDocumentModelModuleById(documentType);
10548
+ if (!documentId || !documentType)
10549
+ return [];
10550
+ if (!document2) {
10551
+ throw new DocumentNotFoundError(documentId);
10552
+ }
10553
+ if (!documentModelModule) {
10554
+ throw new DocumentModelNotFoundError(documentType);
10555
+ }
10556
+ if (document2.header.documentType !== documentType) {
10557
+ throw new DocumentTypeMismatchError(documentId, documentType, document2.header.documentType);
10558
+ }
10559
+ return [document2, dispatch];
10326
10560
  }
10327
10561
  // src/hooks/document-operations.ts
10328
- import { useCallback as useCallback3, useEffect as useEffect3, useRef as useRef2, useState as useState3 } from "react";
10562
+ import { useCallback as useCallback4, useEffect as useEffect4, useRef as useRef2, useState as useState4 } from "react";
10329
10563
  function useDocumentOperations(documentId) {
10330
10564
  const reactorClient = useReactorClient();
10331
10565
  const hasFetchedRef = useRef2(false);
10332
- const [state, setState] = useState3(() => ({
10566
+ const [state, setState] = useState4(() => ({
10333
10567
  globalOperations: [],
10334
10568
  localOperations: [],
10335
10569
  isLoading: !!documentId,
10336
10570
  error: undefined
10337
10571
  }));
10338
- const fetchOperations = useCallback3(async (retryCount = 0) => {
10572
+ const fetchOperations = useCallback4(async (retryCount = 0) => {
10339
10573
  const MAX_RETRIES = 5;
10340
10574
  const RETRY_DELAY_MS = 500;
10341
10575
  if (!documentId || !reactorClient) {
@@ -10381,7 +10615,7 @@ function useDocumentOperations(documentId) {
10381
10615
  });
10382
10616
  hasFetchedRef.current = true;
10383
10617
  }, [documentId, reactorClient]);
10384
- useEffect3(() => {
10618
+ useEffect4(() => {
10385
10619
  if (documentId && reactorClient) {
10386
10620
  fetchOperations();
10387
10621
  } else if (!documentId) {
@@ -10394,7 +10628,7 @@ function useDocumentOperations(documentId) {
10394
10628
  hasFetchedRef.current = false;
10395
10629
  }
10396
10630
  }, [documentId, reactorClient, fetchOperations]);
10397
- const refetch = useCallback3(() => {
10631
+ const refetch = useCallback4(() => {
10398
10632
  fetchOperations(0);
10399
10633
  }, [fetchOperations]);
10400
10634
  return { ...state, refetch };
@@ -10981,145 +11215,6 @@ function makeVetraPackageManifestModulesEntry(modules) {
10981
11215
  return acc;
10982
11216
  }, {});
10983
11217
  }
10984
-
10985
- // src/renown/utils.ts
10986
- import { logger as logger6 } from "document-drive";
10987
-
10988
- // src/renown/constants.ts
10989
- var RENOWN_URL = "https://www.renown.id";
10990
- var RENOWN_NETWORK_ID = "eip155";
10991
- var RENOWN_CHAIN_ID = "1";
10992
- var DOMAIN_TYPE = [
10993
- { name: "name", type: "string" },
10994
- { name: "version", type: "string" },
10995
- { name: "chainId", type: "uint256" },
10996
- { name: "verifyingContract", type: "address" }
10997
- ];
10998
- var VERIFIABLE_CREDENTIAL_EIP712_TYPE = [
10999
- { name: "@context", type: "string[]" },
11000
- { name: "type", type: "string[]" },
11001
- { name: "id", type: "string" },
11002
- { name: "issuer", type: "Issuer" },
11003
- { name: "credentialSubject", type: "CredentialSubject" },
11004
- { name: "credentialSchema", type: "CredentialSchema" },
11005
- { name: "issuanceDate", type: "string" },
11006
- { name: "expirationDate", type: "string" }
11007
- ];
11008
- var CREDENTIAL_SCHEMA_EIP712_TYPE = [
11009
- { name: "id", type: "string" },
11010
- { name: "type", type: "string" }
11011
- ];
11012
- var CREDENTIAL_SUBJECT_TYPE = [
11013
- { name: "app", type: "string" },
11014
- { name: "id", type: "string" },
11015
- { name: "name", type: "string" }
11016
- ];
11017
- var ISSUER_TYPE = [
11018
- { name: "id", type: "string" },
11019
- { name: "ethereumAddress", type: "string" }
11020
- ];
11021
- var CREDENTIAL_TYPES = {
11022
- EIP712Domain: DOMAIN_TYPE,
11023
- VerifiableCredential: VERIFIABLE_CREDENTIAL_EIP712_TYPE,
11024
- CredentialSchema: CREDENTIAL_SCHEMA_EIP712_TYPE,
11025
- CredentialSubject: CREDENTIAL_SUBJECT_TYPE,
11026
- Issuer: ISSUER_TYPE
11027
- };
11028
-
11029
- // src/renown/utils.ts
11030
- function openRenown(documentId) {
11031
- if (documentId) {
11032
- window.open(`${RENOWN_URL}/profile/${documentId}`, "_blank")?.focus();
11033
- return;
11034
- }
11035
- const url = new URL(RENOWN_URL);
11036
- url.searchParams.set("connect", window.ph?.renown?.did ?? "");
11037
- url.searchParams.set("network", RENOWN_NETWORK_ID);
11038
- url.searchParams.set("chain", RENOWN_CHAIN_ID);
11039
- const returnUrl = new URL(window.location.pathname, window.location.origin);
11040
- url.searchParams.set("returnUrl", returnUrl.toJSON());
11041
- window.open(url, "_self")?.focus();
11042
- }
11043
- function consumeDidFromUrl() {
11044
- if (typeof window === "undefined")
11045
- return;
11046
- const urlParams = new URLSearchParams(window.location.search);
11047
- const userParam = urlParams.get("user");
11048
- if (!userParam)
11049
- return;
11050
- const userDid = decodeURIComponent(userParam);
11051
- const cleanUrl = new URL(window.location.href);
11052
- cleanUrl.searchParams.delete("user");
11053
- window.history.replaceState({}, "", cleanUrl.toString());
11054
- return userDid;
11055
- }
11056
- async function login(userDid, renown) {
11057
- if (!renown) {
11058
- return;
11059
- }
11060
- const did = userDid ?? consumeDidFromUrl();
11061
- try {
11062
- const user = renown.user;
11063
- if (user?.did && (user.did === did || !did)) {
11064
- return user;
11065
- }
11066
- if (!did) {
11067
- return;
11068
- }
11069
- return await renown.login(did);
11070
- } catch (error) {
11071
- logger6.error("@error", error);
11072
- }
11073
- }
11074
- async function logout() {
11075
- const renown = window.ph?.renown;
11076
- await renown?.logout();
11077
- const url = new URL(window.location.href);
11078
- if (url.searchParams.has("user")) {
11079
- url.searchParams.delete("user");
11080
- window.history.replaceState(null, "", url.toString());
11081
- }
11082
- }
11083
- // src/hooks/loading.ts
11084
- var {
11085
- useValue: useLoading,
11086
- setValue: setLoading,
11087
- addEventHandler: addLoadingEventHandler
11088
- } = makePHEventFunctions("loading");
11089
-
11090
- // src/hooks/renown.ts
11091
- import { useEffect as useEffect4, useState as useState4 } from "react";
11092
- var renownEventFunctions = makePHEventFunctions("renown");
11093
- var useRenown = renownEventFunctions.useValue;
11094
- var setRenown = renownEventFunctions.setValue;
11095
- function useDid() {
11096
- const renown = useRenown();
11097
- return renown?.did;
11098
- }
11099
- function useUser() {
11100
- const renown = useRenown();
11101
- const [user, setUser] = useState4(() => renown?.user);
11102
- useEffect4(() => {
11103
- setUser(renown?.user);
11104
- if (!renown)
11105
- return;
11106
- return renown.on("user", setUser);
11107
- }, [renown]);
11108
- return user;
11109
- }
11110
- function useLoginStatus() {
11111
- const renown = useRenown();
11112
- const [status, setStatus] = useState4(() => renown ? renown.status : "initializing");
11113
- useEffect4(() => {
11114
- setStatus(renown ? renown.status : "initializing");
11115
- if (!renown)
11116
- return;
11117
- return renown.on("status", setStatus);
11118
- }, [renown]);
11119
- return status;
11120
- }
11121
- var addRenownEventHandler = renownEventFunctions.addEventHandler;
11122
-
11123
11218
  // src/hooks/add-ph-event-handlers.ts
11124
11219
  var phGlobalEventHandlerRegisterFunctions = {
11125
11220
  loading: addLoadingEventHandler,
@@ -11259,6 +11354,49 @@ function useUserPermissions() {
11259
11354
  isAllowedToEditDocuments: allowList.includes(user?.address ?? "")
11260
11355
  };
11261
11356
  }
11357
+ // src/registry/client.ts
11358
+ function cdnUrlToApiUrl(cdnUrl) {
11359
+ return cdnUrl.replace(/\/-\/cdn\/?$/, "");
11360
+ }
11361
+ function mapPackageInfo(pkg) {
11362
+ return {
11363
+ name: pkg.name,
11364
+ description: pkg.manifest?.description,
11365
+ version: pkg.manifest?.version,
11366
+ category: pkg.manifest?.category,
11367
+ publisher: pkg.manifest?.publisher?.name,
11368
+ publisherUrl: pkg.manifest?.publisher?.url
11369
+ };
11370
+ }
11371
+
11372
+ class RegistryClient {
11373
+ apiUrl;
11374
+ constructor(cdnUrl) {
11375
+ this.apiUrl = cdnUrlToApiUrl(cdnUrl);
11376
+ }
11377
+ async getPackages() {
11378
+ const res = await fetch(`${this.apiUrl}/packages`);
11379
+ if (!res.ok)
11380
+ throw new Error(`Registry error: HTTP ${res.status}`);
11381
+ const data = await res.json();
11382
+ return data.map(mapPackageInfo);
11383
+ }
11384
+ async getPackagesByDocumentType(documentType) {
11385
+ const encodedType = encodeURIComponent(documentType);
11386
+ const res = await fetch(`${this.apiUrl}/packages/by-document-type?type=${encodedType}`);
11387
+ if (!res.ok)
11388
+ throw new Error(`Registry error: HTTP ${res.status}`);
11389
+ return await res.json();
11390
+ }
11391
+ async searchPackages(query) {
11392
+ const packages = await this.getPackages();
11393
+ if (!query)
11394
+ return packages;
11395
+ const lowerQuery = query.toLowerCase();
11396
+ return packages.filter((pkg) => pkg.name.toLowerCase().includes(lowerQuery) || pkg.description?.toLowerCase().includes(lowerQuery));
11397
+ }
11398
+ }
11399
+
11262
11400
  // src/storage/base-storage.ts
11263
11401
  class BaseStorage {
11264
11402
  #store;
@@ -11305,6 +11443,20 @@ class BrowserLocalStorage extends BaseStorage {
11305
11443
  }
11306
11444
 
11307
11445
  // src/package-manager.ts
11446
+ var DISMISSED_STORAGE_KEY = "ph-connect-dismissed-packages";
11447
+ function loadDismissedPackages() {
11448
+ try {
11449
+ const raw = localStorage.getItem(DISMISSED_STORAGE_KEY);
11450
+ if (raw)
11451
+ return JSON.parse(raw);
11452
+ } catch {}
11453
+ return [];
11454
+ }
11455
+ function persistDismissedPackages(dismissed) {
11456
+ try {
11457
+ localStorage.setItem(DISMISSED_STORAGE_KEY, JSON.stringify(dismissed));
11458
+ } catch {}
11459
+ }
11308
11460
  function loadCSS(pkg, registryUrl) {
11309
11461
  const head = document.getElementsByTagName("head")[0];
11310
11462
  const existingStyle = head.querySelector(`link[data-package='${pkg}']`);
@@ -11325,10 +11477,13 @@ function removeCSS(pkg) {
11325
11477
  style.remove();
11326
11478
  }
11327
11479
  }
11480
+ async function runtimeImport(url) {
11481
+ return new Function("u", "return import(u)")(url);
11482
+ }
11328
11483
  async function loadExternalPackage(name, registryUrl) {
11329
11484
  registryUrl = registryUrl.endsWith("/") ? registryUrl : `${registryUrl}/`;
11330
11485
  const url = `${registryUrl}${name}/index.js`;
11331
- const module = await import(url);
11486
+ const module = await runtimeImport(url);
11332
11487
  loadCSS(name, registryUrl);
11333
11488
  return convertLegacyLibToVetraPackage(module);
11334
11489
  }
@@ -11339,12 +11494,23 @@ class BrowserPackageManager {
11339
11494
  #localPackageIds = new Set;
11340
11495
  #subscribers = new Set;
11341
11496
  #packagesMemo = [];
11342
- constructor(namespace) {
11497
+ #registryCdnUrl;
11498
+ #registryClient;
11499
+ #documentModelRegistry;
11500
+ #pending = [];
11501
+ #dismissed = loadDismissedPackages();
11502
+ #deferredActions = new Map;
11503
+ #pendingListeners = new Set;
11504
+ constructor(namespace, registryCdnUrl) {
11343
11505
  this.#storage = new BrowserLocalStorage(namespace + ":PH_PACKAGES");
11344
11506
  const packages = this.#storage.get("packages");
11345
11507
  if (!packages) {
11346
11508
  this.#storage.set("packages", []);
11347
11509
  }
11510
+ if (registryCdnUrl) {
11511
+ this.#registryCdnUrl = registryCdnUrl;
11512
+ this.#registryClient = new RegistryClient(registryCdnUrl);
11513
+ }
11348
11514
  }
11349
11515
  async init() {
11350
11516
  const packages = this.#storage.get("packages");
@@ -11400,6 +11566,99 @@ class BrowserPackageManager {
11400
11566
  handler({ packages });
11401
11567
  });
11402
11568
  }
11569
+ setDocumentModelRegistry(registry) {
11570
+ this.#documentModelRegistry = registry;
11571
+ }
11572
+ async load(documentType) {
11573
+ if (!this.#registryClient || !this.#registryCdnUrl) {
11574
+ throw new Error("Registry CDN URL not configured — cannot discover packages");
11575
+ }
11576
+ const packageNames = await this.#registryClient.getPackagesByDocumentType(documentType);
11577
+ if (packageNames.length === 0) {
11578
+ throw new Error(`No package found containing document type: ${documentType}`);
11579
+ }
11580
+ const packageName = packageNames.sort((a, b) => a.localeCompare(b))[0];
11581
+ this.#pending = [...this.#pending, { documentType, packageName }];
11582
+ this.#notifyPendingListeners();
11583
+ return new Promise((resolve, reject) => {
11584
+ this.#deferredActions.set(packageName, { resolve, reject });
11585
+ });
11586
+ }
11587
+ async approveInstallation(packageName) {
11588
+ const deferred = this.#deferredActions.get(packageName);
11589
+ if (!deferred)
11590
+ return;
11591
+ try {
11592
+ await this.addPackage(packageName, this.#registryCdnUrl);
11593
+ } catch (error) {
11594
+ this.#removePending(packageName);
11595
+ this.#deferredActions.delete(packageName);
11596
+ deferred.reject(error instanceof Error ? error : new Error(`Failed to install package: ${packageName}`));
11597
+ return;
11598
+ }
11599
+ const pendingEntries = this.#pending.filter((p) => p.packageName === packageName);
11600
+ this.#removePending(packageName);
11601
+ this.#deferredActions.delete(packageName);
11602
+ if (!this.#documentModelRegistry) {
11603
+ deferred.reject(new Error("Document model registry not available"));
11604
+ return;
11605
+ }
11606
+ for (const entry of pendingEntries) {
11607
+ try {
11608
+ const module = this.#documentModelRegistry.getModule(entry.documentType);
11609
+ deferred.resolve(module);
11610
+ return;
11611
+ } catch {}
11612
+ }
11613
+ deferred.reject(new Error(`Module not found after installing package: ${packageName}`));
11614
+ }
11615
+ rejectInstallation(packageName) {
11616
+ const deferred = this.#deferredActions.get(packageName);
11617
+ if (!deferred)
11618
+ return;
11619
+ const rejectedEntries = this.#pending.filter((p) => p.packageName === packageName);
11620
+ const documentTypes = rejectedEntries.map((e) => e.documentType);
11621
+ this.#addDismissed(packageName, documentTypes);
11622
+ this.#removePending(packageName);
11623
+ this.#deferredActions.delete(packageName);
11624
+ deferred.reject(new Error(`Installation rejected for package: ${packageName}`));
11625
+ }
11626
+ subscribePendingChanges(listener) {
11627
+ this.#pendingListeners.add(listener);
11628
+ return () => {
11629
+ this.#pendingListeners.delete(listener);
11630
+ };
11631
+ }
11632
+ getPendingInstallations() {
11633
+ return this.#pending;
11634
+ }
11635
+ getDismissedPackages() {
11636
+ return this.#dismissed;
11637
+ }
11638
+ removeDismissed(packageName) {
11639
+ this.#dismissed = this.#dismissed.filter((d) => d.packageName !== packageName);
11640
+ persistDismissedPackages(this.#dismissed);
11641
+ this.#notifyPendingListeners();
11642
+ }
11643
+ #addDismissed(packageName, documentTypes) {
11644
+ const existing = this.#dismissed.find((d) => d.packageName === packageName);
11645
+ if (existing) {
11646
+ const merged = new Set([...existing.documentTypes, ...documentTypes]);
11647
+ existing.documentTypes = [...merged];
11648
+ } else {
11649
+ this.#dismissed = [...this.#dismissed, { packageName, documentTypes }];
11650
+ }
11651
+ persistDismissedPackages(this.#dismissed);
11652
+ }
11653
+ #removePending(packageName) {
11654
+ this.#pending = this.#pending.filter((p) => p.packageName !== packageName);
11655
+ this.#notifyPendingListeners();
11656
+ }
11657
+ #notifyPendingListeners() {
11658
+ for (const listener of this.#pendingListeners) {
11659
+ listener();
11660
+ }
11661
+ }
11403
11662
  }
11404
11663
  // src/pglite/drop.ts
11405
11664
  import { REACTOR_SCHEMA } from "@powerhousedao/reactor";
@@ -11468,52 +11727,17 @@ var usePGlite2 = () => {
11468
11727
  import {
11469
11728
  ChannelScheme,
11470
11729
  ConsoleLogger,
11471
- DocumentChangeType,
11472
- driveCollectionId as driveCollectionId3,
11473
- GqlRequestChannel as GqlRequestChannel2,
11474
- InMemoryQueue,
11475
- IntervalPollTimer,
11476
- REACTOR_SCHEMA as REACTOR_SCHEMA2,
11477
- ReactorBuilder,
11478
- ReactorClientBuilder,
11479
- RelationalDbProcessor,
11480
- SyncOperationStatus
11481
- } from "@powerhousedao/reactor";
11482
- // src/registry/client.ts
11483
- function cdnUrlToApiUrl(cdnUrl) {
11484
- return cdnUrl.replace(/\/-\/cdn\/?$/, "");
11485
- }
11486
- function mapPackageInfo(pkg) {
11487
- return {
11488
- name: pkg.name,
11489
- description: pkg.manifest?.description,
11490
- version: pkg.manifest?.version,
11491
- category: pkg.manifest?.category,
11492
- publisher: pkg.manifest?.publisher?.name,
11493
- publisherUrl: pkg.manifest?.publisher?.url
11494
- };
11495
- }
11496
-
11497
- class RegistryClient {
11498
- apiUrl;
11499
- constructor(cdnUrl) {
11500
- this.apiUrl = cdnUrlToApiUrl(cdnUrl);
11501
- }
11502
- async getPackages() {
11503
- const res = await fetch(`${this.apiUrl}/packages`);
11504
- if (!res.ok)
11505
- throw new Error(`Registry error: HTTP ${res.status}`);
11506
- const data = await res.json();
11507
- return data.map(mapPackageInfo);
11508
- }
11509
- async searchPackages(query) {
11510
- const packages = await this.getPackages();
11511
- if (!query)
11512
- return packages;
11513
- const lowerQuery = query.toLowerCase();
11514
- return packages.filter((pkg) => pkg.name.toLowerCase().includes(lowerQuery) || pkg.description?.toLowerCase().includes(lowerQuery));
11515
- }
11516
- }
11730
+ DocumentChangeType,
11731
+ driveCollectionId as driveCollectionId3,
11732
+ GqlRequestChannel as GqlRequestChannel2,
11733
+ InMemoryQueue,
11734
+ IntervalPollTimer,
11735
+ REACTOR_SCHEMA as REACTOR_SCHEMA2,
11736
+ ReactorBuilder,
11737
+ ReactorClientBuilder,
11738
+ RelationalDbProcessor,
11739
+ SyncOperationStatus
11740
+ } from "@powerhousedao/reactor";
11517
11741
  // src/reactor-client-document-cache.ts
11518
11742
  import {
11519
11743
  DocumentChangeType as DocumentChangeType2
@@ -30428,7 +30652,7 @@ function useRelationalQuery(ProcessorClass, driveId, queryCallback, parameters,
30428
30652
 
30429
30653
  // src/relational/utils/createProcessorQuery.ts
30430
30654
  var import_lodash = __toESM(require_lodash(), 1);
30431
- import { useCallback as useCallback4, useMemo as useMemo3, useRef as useRef4 } from "react";
30655
+ import { useCallback as useCallback5, useMemo as useMemo3, useRef as useRef4 } from "react";
30432
30656
  function useStableParams(params) {
30433
30657
  const prevParamsRef = useRef4(null);
30434
30658
  return useMemo3(() => {
@@ -30441,7 +30665,7 @@ function useStableParams(params) {
30441
30665
  function createProcessorQuery(ProcessorClass) {
30442
30666
  function useQuery(driveId, queryCallback, parameters, options) {
30443
30667
  const stableParams = useStableParams(parameters);
30444
- const memoizedCallback = useCallback4(queryCallback, [stableParams]);
30668
+ const memoizedCallback = useCallback5(queryCallback, [stableParams]);
30445
30669
  return useRelationalQuery(ProcessorClass, driveId, memoizedCallback, stableParams, options);
30446
30670
  }
30447
30671
  return useQuery;
@@ -30922,7 +31146,7 @@ class RemoteDocumentController {
30922
31146
  }
30923
31147
  }
30924
31148
  // src/renown/components/RenownLoginButton.tsx
30925
- import { useCallback as useCallback5, useEffect as useEffect7, useRef as useRef5, useState as useState7 } from "react";
31149
+ import { useCallback as useCallback6, useState as useState7 } from "react";
30926
31150
 
30927
31151
  // src/renown/components/icons.tsx
30928
31152
  import { jsxDEV } from "react/jsx-dev-runtime";
@@ -30991,41 +31215,6 @@ function CopyIcon({ size = 14, color = "#9EA0A1" }) {
30991
31215
  ]
30992
31216
  }, undefined, true, undefined, this);
30993
31217
  }
30994
- function ExternalLinkIcon({
30995
- size = 14,
30996
- color = "currentColor"
30997
- }) {
30998
- return /* @__PURE__ */ jsxDEV("svg", {
30999
- width: size,
31000
- height: size,
31001
- viewBox: "0 0 16 16",
31002
- fill: "none",
31003
- xmlns: "http://www.w3.org/2000/svg",
31004
- children: [
31005
- /* @__PURE__ */ jsxDEV("path", {
31006
- d: "M12 8.66667V12.6667C12 13.0203 11.8595 13.3594 11.6095 13.6095C11.3594 13.8595 11.0203 14 10.6667 14H3.33333C2.97971 14 2.64057 13.8595 2.39052 13.6095C2.14048 13.3594 2 13.0203 2 12.6667V5.33333C2 4.97971 2.14048 4.64057 2.39052 4.39052C2.64057 4.14048 2.97971 4 3.33333 4H7.33333",
31007
- stroke: color,
31008
- strokeWidth: "1.5",
31009
- strokeLinecap: "round",
31010
- strokeLinejoin: "round"
31011
- }, undefined, false, undefined, this),
31012
- /* @__PURE__ */ jsxDEV("path", {
31013
- d: "M10 2H14V6",
31014
- stroke: color,
31015
- strokeWidth: "1.5",
31016
- strokeLinecap: "round",
31017
- strokeLinejoin: "round"
31018
- }, undefined, false, undefined, this),
31019
- /* @__PURE__ */ jsxDEV("path", {
31020
- d: "M6.66669 9.33333L14 2",
31021
- stroke: color,
31022
- strokeWidth: "1.5",
31023
- strokeLinecap: "round",
31024
- strokeLinejoin: "round"
31025
- }, undefined, false, undefined, this)
31026
- ]
31027
- }, undefined, true, undefined, this);
31028
- }
31029
31218
  function DisconnectIcon({ size = 14, color = "#EA4335" }) {
31030
31219
  return /* @__PURE__ */ jsxDEV("svg", {
31031
31220
  width: size,
@@ -31128,6 +31317,27 @@ function SpinnerIcon({ size = 14, color = "currentColor" }) {
31128
31317
  ]
31129
31318
  }, undefined, true, undefined, this);
31130
31319
  }
31320
+ function ChevronDownIcon({
31321
+ size = 14,
31322
+ color = "currentColor",
31323
+ style
31324
+ }) {
31325
+ return /* @__PURE__ */ jsxDEV("svg", {
31326
+ width: size,
31327
+ height: size,
31328
+ viewBox: "0 0 16 16",
31329
+ fill: "none",
31330
+ xmlns: "http://www.w3.org/2000/svg",
31331
+ style,
31332
+ children: /* @__PURE__ */ jsxDEV("path", {
31333
+ d: "M4 6L8 10L12 6",
31334
+ stroke: color,
31335
+ strokeWidth: "1.5",
31336
+ strokeLinecap: "round",
31337
+ strokeLinejoin: "round"
31338
+ }, undefined, false, undefined, this)
31339
+ }, undefined, false, undefined, this);
31340
+ }
31131
31341
  function UserIcon({ size = 24, color = "#6366f1" }) {
31132
31342
  return /* @__PURE__ */ jsxDEV("svg", {
31133
31343
  width: size,
@@ -31153,80 +31363,93 @@ function UserIcon({ size = 24, color = "#6366f1" }) {
31153
31363
  }, undefined, true, undefined, this);
31154
31364
  }
31155
31365
 
31156
- // src/renown/components/image-data.ts
31157
- var renownShortDataUrl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJAAAACQCAYAAADnRuK4AAAACXBIWXMAACxLAAAsSwGlPZapAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAtmSURBVHgB7Z3dbtvmGsefl5LsqHYCq0C6tEUCZ0kDzAFqd0NTYAmweAfr0YD0CrpeQboriH0H6RUsu4ChAYodtCdJD3LQBGttILEBJ4tdJ2uzBoi0yIpsi+S790+ZDkmREilSHySfX6FKpkgliH5+nuf9pKAEkFLO1Bu7VzRNzEuiWfXzglDHSIgZYsYC9b1sCaEeJFZMU66WCnS7XC5vUUwE9Qmk2dndvar+ZpetB5NCxIr6Hr+II1NkgQ7FMeTnHGGygxLhRkGj5agiRRKo3mxeY3EyjkZLR8vl5bCnhxKo2WzOGqb4UpJcCDpH1T+E/wpKY+3gU4XoO0MyCaKyhvVsqifTNNWzVM8y8Hz1rW2pr3ExTDTq+Q3vNPc/lYZ+3S/qwI+iVlDSCJYlZ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CQBPyeGtjTF+4lwLJNKYbRlmoqk61ECHF8UYfBspzmL6M1ybHjh1rjzY0fiQOtVvHolEFYpEIEOElo2oyAjlRFZhrCWRPphaKQpTKwosqxPHKI6qftZY8CPOelBxKvy8C10LnscZYFBSFAREeMHWlM6rrGBMjz81T43Odx/KWc6gKX+adYM1kVRpgDBGa6LKPZL2ZhyeyDC7zts0TCMMT5+xHrlPFhjZSOgs+mLb8AgaHyE3O1GXhu6CstTn+HOiw1ns8K2oiLKooGgUP2dsS1xa3fPS1rU2Nm/3OG7WwSSZTa4Riq/NOEskwGlHkRtQ/GHVUn7EeA31tS1PTmkLnjlkZDwwMdbEIe9bZvbdPNkWKiAIbXxP1A8qi6tjL4gXE4QkmSplmzEajUNRVP5ZKdcY4vCZ+TmehNthLU5ghEr7GLyapJgeWIFgc44y638SoE1wjlmV8mV/Nk9cWSqBQSiOCApdjgS0t8TXFnlFyiMBoFNH0NYwpK4EICIY4avOU7g7mXeI8OmXnGEMkuFSEuzu8A49EncDEhKgGb5QjTu4rqoAtkxSJLeAMOsUXdwIxSeAJvHkC1/CIAZ39uJJQa5qyuVxpnHwGk1vpUB2et44AAAAASUVORK5CYII=";
31366
+ // src/renown/components/slot.tsx
31367
+ import {
31368
+ Children,
31369
+ cloneElement,
31370
+ forwardRef,
31371
+ isValidElement
31372
+ } from "react";
31373
+ function mergeProps(parentProps, childProps) {
31374
+ const merged = { ...parentProps };
31375
+ for (const key of Object.keys(childProps)) {
31376
+ const parentValue = parentProps[key];
31377
+ const childValue = childProps[key];
31378
+ if (key === "style") {
31379
+ merged[key] = { ...parentValue, ...childValue };
31380
+ } else if (key === "className") {
31381
+ merged[key] = [parentValue, childValue].filter(Boolean).join(" ");
31382
+ } else if (typeof parentValue === "function" && typeof childValue === "function") {
31383
+ merged[key] = (...args) => {
31384
+ childValue(...args);
31385
+ parentValue(...args);
31386
+ };
31387
+ } else if (childValue !== undefined) {
31388
+ merged[key] = childValue;
31389
+ }
31390
+ }
31391
+ return merged;
31392
+ }
31393
+ var Slot = forwardRef(({ children, ...props }, ref) => {
31394
+ const child = Children.only(children);
31395
+ if (!isValidElement(child)) {
31396
+ return null;
31397
+ }
31398
+ const childElement = child;
31399
+ const mergedProps = mergeProps(props, childElement.props);
31400
+ if (ref) {
31401
+ mergedProps.ref = ref;
31402
+ }
31403
+ return cloneElement(childElement, mergedProps);
31404
+ });
31405
+ Slot.displayName = "Slot";
31159
31406
 
31160
31407
  // src/renown/components/RenownLoginButton.tsx
31161
31408
  import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
31162
- var POPOVER_GAP = 8;
31163
- var POPOVER_HEIGHT = 120;
31164
- var styles = {
31409
+ var lightStyles = {
31165
31410
  trigger: {
31166
- display: "flex",
31167
- alignItems: "center",
31168
- justifyContent: "center",
31169
- padding: 0,
31170
- border: "none",
31171
- background: "transparent",
31172
- cursor: "pointer"
31173
- },
31174
- popoverBase: {
31175
- position: "absolute",
31176
- left: 0,
31177
- borderRadius: "8px",
31178
- width: "208px",
31179
- zIndex: 1000
31180
- },
31181
- popoverLight: {
31182
- backgroundColor: "white",
31183
- boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"
31411
+ backgroundColor: "#ffffff",
31412
+ borderWidth: "1px",
31413
+ borderStyle: "solid",
31414
+ borderColor: "#d1d5db",
31415
+ color: "#111827"
31184
31416
  },
31185
- popoverDark: {
31417
+ triggerHover: {
31418
+ backgroundColor: "#ecf3f8",
31419
+ borderColor: "#9ca3af"
31420
+ }
31421
+ };
31422
+ var darkStyles = {
31423
+ trigger: {
31186
31424
  backgroundColor: "#1f2937",
31187
- boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2)"
31188
- },
31189
- popoverContent: {
31190
- padding: "16px"
31425
+ borderWidth: "1px",
31426
+ borderStyle: "solid",
31427
+ borderColor: "#4b5563",
31428
+ color: "#ecf3f8"
31191
31429
  },
31192
- logoContainer: {
31193
- display: "flex",
31194
- justifyContent: "center",
31195
- height: "22px",
31196
- width: "83px",
31197
- margin: "0 auto 16px",
31198
- overflow: "hidden"
31430
+ triggerHover: {
31431
+ backgroundColor: "#374151",
31432
+ borderColor: "#6b7280"
31433
+ }
31434
+ };
31435
+ var styles = {
31436
+ wrapper: {
31437
+ position: "relative",
31438
+ display: "inline-block"
31199
31439
  },
31200
- connectButtonBase: {
31440
+ trigger: {
31201
31441
  display: "flex",
31202
31442
  alignItems: "center",
31203
31443
  justifyContent: "center",
31204
- width: "100%",
31205
- height: "28px",
31444
+ gap: "8px",
31445
+ padding: "8px 32px",
31206
31446
  borderRadius: "8px",
31207
- backgroundColor: "transparent",
31208
- fontSize: "14px",
31209
31447
  cursor: "pointer",
31210
- marginTop: "16px"
31211
- },
31212
- connectButtonLight: {
31213
- border: "1px solid #d1d5db",
31214
- color: "#111827"
31215
- },
31216
- connectButtonDark: {
31217
- border: "1px solid #4b5563",
31218
- color: "#f9fafb"
31219
- },
31220
- wrapper: {
31221
- position: "relative",
31222
- display: "inline-block"
31223
- },
31224
- triggerImageLight: {
31225
- display: "block"
31226
- },
31227
- triggerImageDark: {
31228
- display: "block",
31229
- filter: "invert(1)"
31448
+ fontSize: "14px",
31449
+ fontWeight: 500,
31450
+ fontFamily: "inherit",
31451
+ lineHeight: "20px",
31452
+ transition: "background-color 150ms, border-color 150ms"
31230
31453
  }
31231
31454
  };
31232
31455
  function RenownLoginButton({
@@ -31234,134 +31457,60 @@ function RenownLoginButton({
31234
31457
  darkMode = false,
31235
31458
  style,
31236
31459
  className,
31237
- renderTrigger,
31238
- showPopover = false
31460
+ asChild = false,
31461
+ children
31239
31462
  }) {
31240
31463
  const onLogin = onLoginProp ?? (() => openRenown());
31241
- const [isOpen, setIsOpen] = useState7(false);
31242
31464
  const [isLoading, setIsLoading] = useState7(false);
31243
31465
  const [isHovered, setIsHovered] = useState7(false);
31244
- const [showAbove, setShowAbove] = useState7(true);
31245
- const wrapperRef = useRef5(null);
31246
- const closeTimeoutRef = useRef5(null);
31247
- const calculatePosition = useCallback5(() => {
31248
- if (!wrapperRef.current)
31249
- return;
31250
- const rect = wrapperRef.current.getBoundingClientRect();
31251
- const spaceAbove = rect.top;
31252
- setShowAbove(spaceAbove >= POPOVER_HEIGHT + POPOVER_GAP);
31253
- }, []);
31254
- const handleMouseEnter = useCallback5(() => {
31255
- setIsHovered(true);
31256
- if (!showPopover)
31257
- return;
31258
- if (closeTimeoutRef.current) {
31259
- clearTimeout(closeTimeoutRef.current);
31260
- closeTimeoutRef.current = null;
31261
- }
31262
- calculatePosition();
31263
- setIsOpen(true);
31264
- }, [calculatePosition, showPopover]);
31265
- const handleMouseLeave = useCallback5(() => {
31266
- closeTimeoutRef.current = setTimeout(() => {
31267
- setIsOpen(false);
31268
- setIsHovered(false);
31269
- }, 150);
31270
- }, []);
31271
- useEffect7(() => {
31272
- return () => {
31273
- if (closeTimeoutRef.current) {
31274
- clearTimeout(closeTimeoutRef.current);
31275
- }
31276
- };
31277
- }, []);
31278
- const handleConnect = () => {
31279
- setIsLoading(true);
31280
- onLogin();
31281
- };
31282
- const handleDirectClick = () => {
31283
- if (!showPopover && !isLoading) {
31466
+ const handleMouseEnter = useCallback6(() => setIsHovered(true), []);
31467
+ const handleMouseLeave = useCallback6(() => setIsHovered(false), []);
31468
+ const handleClick = () => {
31469
+ if (!isLoading) {
31284
31470
  setIsLoading(true);
31285
31471
  onLogin();
31286
31472
  }
31287
31473
  };
31474
+ const themeStyles = darkMode ? darkStyles : lightStyles;
31288
31475
  const triggerStyle = {
31289
31476
  ...styles.trigger,
31290
- cursor: !isLoading ? "pointer" : "wait",
31477
+ ...themeStyles.trigger,
31478
+ ...isHovered && !isLoading ? themeStyles.triggerHover : {},
31479
+ cursor: isLoading ? "wait" : "pointer",
31291
31480
  ...style
31292
31481
  };
31293
- const allowLogin = !isLoading && !!onLogin;
31294
- const connectButtonStyle = {
31295
- ...styles.connectButtonBase,
31296
- ...darkMode ? styles.connectButtonDark : styles.connectButtonLight,
31297
- cursor: allowLogin ? "pointer" : "wait"
31298
- };
31299
- const popoverStyle = {
31300
- ...styles.popoverBase,
31301
- ...darkMode ? styles.popoverDark : styles.popoverLight,
31302
- ...showAbove ? { bottom: `calc(100% + ${POPOVER_GAP}px)` } : { top: `calc(100% + ${POPOVER_GAP}px)` }
31303
- };
31304
- const triggerImageStyle = darkMode ? styles.triggerImageDark : styles.triggerImageLight;
31305
- const logoColor = darkMode ? "#f9fafb" : "#374151";
31482
+ const triggerElement = asChild ? /* @__PURE__ */ jsxDEV2(Slot, {
31483
+ onClick: handleClick,
31484
+ "data-renown-state": "login",
31485
+ ...isLoading ? { "data-loading": "" } : {},
31486
+ children
31487
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV2("button", {
31488
+ type: "button",
31489
+ style: triggerStyle,
31490
+ "aria-label": "Log in with Renown",
31491
+ onClick: handleClick,
31492
+ "data-renown-state": "login",
31493
+ ...isLoading ? { "data-loading": "" } : {},
31494
+ children: isLoading ? /* @__PURE__ */ jsxDEV2(SpinnerIcon, {
31495
+ size: 16
31496
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV2("span", {
31497
+ children: "Log in"
31498
+ }, undefined, false, undefined, this)
31499
+ }, undefined, false, undefined, this);
31306
31500
  return /* @__PURE__ */ jsxDEV2("div", {
31307
- ref: wrapperRef,
31308
31501
  style: styles.wrapper,
31309
31502
  className,
31310
31503
  onMouseEnter: handleMouseEnter,
31311
31504
  onMouseLeave: handleMouseLeave,
31312
- children: [
31313
- renderTrigger ? renderTrigger({
31314
- onMouseEnter: handleMouseEnter,
31315
- onMouseLeave: handleMouseLeave,
31316
- isLoading
31317
- }) : /* @__PURE__ */ jsxDEV2("button", {
31318
- type: "button",
31319
- style: triggerStyle,
31320
- "aria-label": showPopover ? "Open Renown Login" : "Login with Renown",
31321
- onClick: showPopover ? undefined : handleDirectClick,
31322
- children: isLoading ? /* @__PURE__ */ jsxDEV2(SpinnerIcon, {
31323
- size: 42
31324
- }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV2("img", {
31325
- width: 42,
31326
- height: 42,
31327
- src: isHovered ? renownShortHoverDataUrl : renownShortDataUrl,
31328
- alt: "Renown Login",
31329
- style: triggerImageStyle
31330
- }, undefined, false, undefined, this)
31331
- }, undefined, false, undefined, this),
31332
- isOpen && showPopover && /* @__PURE__ */ jsxDEV2("div", {
31333
- style: popoverStyle,
31334
- children: /* @__PURE__ */ jsxDEV2("div", {
31335
- style: styles.popoverContent,
31336
- children: [
31337
- /* @__PURE__ */ jsxDEV2("div", {
31338
- style: styles.logoContainer,
31339
- children: /* @__PURE__ */ jsxDEV2(RenownLogo, {
31340
- width: 83,
31341
- height: 22,
31342
- color: logoColor
31343
- }, undefined, false, undefined, this)
31344
- }, undefined, false, undefined, this),
31345
- /* @__PURE__ */ jsxDEV2("button", {
31346
- type: "button",
31347
- onClick: allowLogin ? handleConnect : undefined,
31348
- style: connectButtonStyle,
31349
- children: isLoading ? /* @__PURE__ */ jsxDEV2(SpinnerIcon, {
31350
- size: 14
31351
- }, undefined, false, undefined, this) : "Connect"
31352
- }, undefined, false, undefined, this)
31353
- ]
31354
- }, undefined, true, undefined, this)
31355
- }, undefined, false, undefined, this)
31356
- ]
31357
- }, undefined, true, undefined, this);
31505
+ children: triggerElement
31506
+ }, undefined, false, undefined, this);
31358
31507
  }
31359
31508
 
31360
31509
  // src/renown/components/RenownUserButton.tsx
31361
- import { useCallback as useCallback6, useEffect as useEffect8, useRef as useRef6, useState as useState8 } from "react";
31510
+ import { useCallback as useCallback7, useEffect as useEffect7, useRef as useRef5, useState as useState8 } from "react";
31362
31511
  import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
31363
- var POPOVER_GAP2 = 8;
31364
- var POPOVER_HEIGHT2 = 150;
31512
+ var POPOVER_GAP = 4;
31513
+ var POPOVER_HEIGHT = 150;
31365
31514
  var styles2 = {
31366
31515
  wrapper: {
31367
31516
  position: "relative",
@@ -31370,56 +31519,89 @@ var styles2 = {
31370
31519
  trigger: {
31371
31520
  display: "flex",
31372
31521
  alignItems: "center",
31373
- justifyContent: "center",
31374
- padding: 0,
31375
- border: "none",
31376
- background: "transparent",
31522
+ gap: "8px",
31523
+ padding: "6px 12px",
31524
+ borderWidth: "1px",
31525
+ borderStyle: "solid",
31526
+ borderColor: "#e5e7eb",
31527
+ backgroundColor: "#ffffff",
31377
31528
  cursor: "pointer",
31378
- borderRadius: "50%",
31379
- overflow: "hidden"
31529
+ borderRadius: "8px",
31530
+ fontSize: "12px",
31531
+ fontWeight: 500,
31532
+ fontFamily: "inherit",
31533
+ color: "#111827",
31534
+ transition: "background-color 150ms, border-color 150ms"
31535
+ },
31536
+ triggerHover: {
31537
+ backgroundColor: "#f9fafb",
31538
+ borderColor: "#9ca3af"
31380
31539
  },
31381
31540
  avatar: {
31382
- width: "40px",
31383
- height: "40px",
31541
+ width: "28px",
31542
+ height: "28px",
31384
31543
  borderRadius: "50%",
31385
- objectFit: "cover"
31544
+ objectFit: "cover",
31545
+ flexShrink: 0
31386
31546
  },
31387
31547
  avatarPlaceholder: {
31388
- width: "40px",
31389
- height: "40px",
31548
+ width: "28px",
31549
+ height: "28px",
31390
31550
  borderRadius: "50%",
31391
- backgroundColor: "#e5e7eb",
31551
+ background: "linear-gradient(135deg, #8b5cf6, #3b82f6)",
31392
31552
  display: "flex",
31393
31553
  alignItems: "center",
31394
- justifyContent: "center"
31554
+ justifyContent: "center",
31555
+ flexShrink: 0
31556
+ },
31557
+ avatarInitial: {
31558
+ fontSize: "12px",
31559
+ fontWeight: 700,
31560
+ color: "#ffffff",
31561
+ lineHeight: 1
31562
+ },
31563
+ displayName: {
31564
+ maxWidth: "120px",
31565
+ overflow: "hidden",
31566
+ textOverflow: "ellipsis",
31567
+ whiteSpace: "nowrap"
31568
+ },
31569
+ chevron: {
31570
+ flexShrink: 0,
31571
+ transition: "transform 150ms",
31572
+ color: "#6b7280"
31573
+ },
31574
+ chevronOpen: {
31575
+ transform: "rotate(180deg)"
31395
31576
  },
31396
31577
  popoverBase: {
31397
31578
  position: "absolute",
31398
- left: 0,
31399
- backgroundColor: "white",
31579
+ right: 0,
31580
+ backgroundColor: "#ffffff",
31400
31581
  borderRadius: "8px",
31401
- boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
31402
- width: "208px",
31582
+ boxShadow: "0 4px 12px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08)",
31583
+ width: "100%",
31403
31584
  zIndex: 1000,
31404
- color: "#111827"
31585
+ color: "#111827",
31586
+ borderWidth: "1px",
31587
+ borderStyle: "solid",
31588
+ borderColor: "#e5e7eb",
31589
+ overflow: "hidden"
31405
31590
  },
31406
- section: {
31407
- padding: "8px 12px",
31591
+ header: {
31592
+ padding: "12px 16px",
31408
31593
  borderBottom: "1px solid #e5e7eb"
31409
31594
  },
31410
- sectionLast: {
31411
- padding: "8px 12px",
31412
- borderBottom: "none"
31413
- },
31414
- username: {
31595
+ headerUsername: {
31415
31596
  fontSize: "14px",
31416
- fontWeight: 500,
31417
- color: "#111827"
31597
+ fontWeight: 600,
31598
+ color: "#111827",
31599
+ margin: 0
31418
31600
  },
31419
31601
  addressRow: {
31420
31602
  display: "flex",
31421
31603
  alignItems: "center",
31422
- gap: "8px",
31604
+ gap: "4px",
31423
31605
  marginTop: "4px"
31424
31606
  },
31425
31607
  addressButton: {
@@ -31428,19 +31610,21 @@ var styles2 = {
31428
31610
  gap: "4px",
31429
31611
  padding: 0,
31430
31612
  border: "none",
31431
- background: "transparent",
31613
+ backgroundColor: "transparent",
31432
31614
  cursor: "pointer",
31433
31615
  fontSize: "12px",
31434
- color: "#111827",
31616
+ color: "#6b7280",
31617
+ fontFamily: "inherit",
31435
31618
  position: "relative",
31436
31619
  width: "100%"
31437
31620
  },
31438
31621
  copiedText: {
31439
31622
  fontSize: "12px",
31440
- color: "#111827",
31623
+ color: "#059669",
31441
31624
  position: "absolute",
31442
31625
  left: 0,
31443
- transition: "opacity 150ms"
31626
+ transition: "opacity 150ms",
31627
+ fontWeight: 500
31444
31628
  },
31445
31629
  addressText: {
31446
31630
  display: "flex",
@@ -31448,24 +31632,38 @@ var styles2 = {
31448
31632
  gap: "4px",
31449
31633
  transition: "opacity 150ms"
31450
31634
  },
31635
+ menuSection: {
31636
+ padding: "4px 0"
31637
+ },
31451
31638
  menuItem: {
31452
31639
  display: "flex",
31453
31640
  alignItems: "center",
31454
31641
  gap: "8px",
31455
31642
  width: "100%",
31456
- padding: 0,
31643
+ padding: "8px 16px",
31457
31644
  border: "none",
31458
- background: "transparent",
31645
+ backgroundColor: "transparent",
31459
31646
  cursor: "pointer",
31460
31647
  fontSize: "14px",
31461
- color: "#111827",
31462
- textDecoration: "none"
31648
+ color: "#374151",
31649
+ textDecoration: "none",
31650
+ fontFamily: "inherit",
31651
+ transition: "background-color 150ms"
31652
+ },
31653
+ menuItemHover: {
31654
+ backgroundColor: "#f3f4f6"
31463
31655
  },
31464
31656
  disconnectItem: {
31465
- color: "#7f1d1d"
31657
+ color: "#dc2626"
31658
+ },
31659
+ separator: {
31660
+ height: "1px",
31661
+ backgroundColor: "#e5e7eb",
31662
+ margin: 0,
31663
+ border: "none"
31466
31664
  }
31467
31665
  };
31468
- function truncateAddress(address) {
31666
+ function truncateAddress2(address) {
31469
31667
  if (address.length <= 13)
31470
31668
  return address;
31471
31669
  return `${address.slice(0, 7)}...${address.slice(-5)}`;
@@ -31478,27 +31676,34 @@ function RenownUserButton({
31478
31676
  onDisconnect: onDisconnectProp,
31479
31677
  style,
31480
31678
  className,
31481
- renderTrigger
31679
+ asChild = false,
31680
+ children,
31681
+ menuItems
31482
31682
  }) {
31483
31683
  const user = useUser();
31484
31684
  const address = addressProp ?? user?.address ?? "";
31485
- const username = usernameProp ?? user?.ens?.name;
31486
- const avatarUrl = avatarUrlProp ?? user?.ens?.avatarUrl;
31685
+ const username = usernameProp ?? user?.profile?.username ?? user?.ens?.name;
31686
+ const avatarUrl = avatarUrlProp ?? user?.profile?.userImage ?? user?.ens?.avatarUrl;
31487
31687
  const userId = userIdProp ?? user?.profile?.documentId;
31488
31688
  const onDisconnect = onDisconnectProp ?? (() => void logout());
31689
+ const displayName = username ?? (address ? truncateAddress2(address) : "Account");
31690
+ const profileId = userId ?? address;
31489
31691
  const [isOpen, setIsOpen] = useState8(false);
31692
+ const [isHovered, setIsHovered] = useState8(false);
31490
31693
  const [isCopied, setIsCopied] = useState8(false);
31491
31694
  const [showAbove, setShowAbove] = useState8(true);
31492
- const wrapperRef = useRef6(null);
31493
- const closeTimeoutRef = useRef6(null);
31494
- const calculatePosition = useCallback6(() => {
31695
+ const [hoveredItem, setHoveredItem] = useState8(null);
31696
+ const wrapperRef = useRef5(null);
31697
+ const closeTimeoutRef = useRef5(null);
31698
+ const calculatePosition = useCallback7(() => {
31495
31699
  if (!wrapperRef.current)
31496
31700
  return;
31497
31701
  const rect = wrapperRef.current.getBoundingClientRect();
31498
31702
  const spaceAbove = rect.top;
31499
- setShowAbove(spaceAbove >= POPOVER_HEIGHT2 + POPOVER_GAP2);
31703
+ setShowAbove(spaceAbove >= POPOVER_HEIGHT + POPOVER_GAP);
31500
31704
  }, []);
31501
- const handleMouseEnter = useCallback6(() => {
31705
+ const handleMouseEnter = useCallback7(() => {
31706
+ setIsHovered(true);
31502
31707
  if (closeTimeoutRef.current) {
31503
31708
  clearTimeout(closeTimeoutRef.current);
31504
31709
  closeTimeoutRef.current = null;
@@ -31506,19 +31711,21 @@ function RenownUserButton({
31506
31711
  calculatePosition();
31507
31712
  setIsOpen(true);
31508
31713
  }, [calculatePosition]);
31509
- const handleMouseLeave = useCallback6(() => {
31714
+ const handleMouseLeave = useCallback7(() => {
31510
31715
  closeTimeoutRef.current = setTimeout(() => {
31511
31716
  setIsOpen(false);
31717
+ setIsHovered(false);
31718
+ setHoveredItem(null);
31512
31719
  }, 150);
31513
31720
  }, []);
31514
- useEffect8(() => {
31721
+ useEffect7(() => {
31515
31722
  return () => {
31516
31723
  if (closeTimeoutRef.current) {
31517
31724
  clearTimeout(closeTimeoutRef.current);
31518
31725
  }
31519
31726
  };
31520
31727
  }, []);
31521
- const copyToClipboard = useCallback6(async () => {
31728
+ const copyToClipboard = useCallback7(async () => {
31522
31729
  try {
31523
31730
  await navigator.clipboard.writeText(address);
31524
31731
  setIsCopied(true);
@@ -31527,6 +31734,43 @@ function RenownUserButton({
31527
31734
  console.error("Failed to copy address:", err);
31528
31735
  }
31529
31736
  }, [address]);
31737
+ const triggerElement = asChild ? /* @__PURE__ */ jsxDEV3(Slot, {
31738
+ "data-renown-state": "authenticated",
31739
+ children
31740
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV3("button", {
31741
+ type: "button",
31742
+ style: {
31743
+ ...styles2.trigger,
31744
+ ...isHovered ? styles2.triggerHover : {},
31745
+ ...style
31746
+ },
31747
+ "aria-label": "Open account menu",
31748
+ "data-renown-state": "authenticated",
31749
+ children: [
31750
+ avatarUrl ? /* @__PURE__ */ jsxDEV3("img", {
31751
+ src: avatarUrl,
31752
+ alt: "Avatar",
31753
+ style: styles2.avatar
31754
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV3("div", {
31755
+ style: styles2.avatarPlaceholder,
31756
+ children: /* @__PURE__ */ jsxDEV3("span", {
31757
+ style: styles2.avatarInitial,
31758
+ children: (displayName || "U")[0].toUpperCase()
31759
+ }, undefined, false, undefined, this)
31760
+ }, undefined, false, undefined, this),
31761
+ /* @__PURE__ */ jsxDEV3("span", {
31762
+ style: styles2.displayName,
31763
+ children: displayName
31764
+ }, undefined, false, undefined, this),
31765
+ /* @__PURE__ */ jsxDEV3(ChevronDownIcon, {
31766
+ size: 14,
31767
+ style: {
31768
+ ...styles2.chevron,
31769
+ ...isOpen ? styles2.chevronOpen : {}
31770
+ }
31771
+ }, undefined, false, undefined, this)
31772
+ ]
31773
+ }, undefined, true, undefined, this);
31530
31774
  return /* @__PURE__ */ jsxDEV3("div", {
31531
31775
  ref: wrapperRef,
31532
31776
  style: styles2.wrapper,
@@ -31534,46 +31778,25 @@ function RenownUserButton({
31534
31778
  onMouseEnter: handleMouseEnter,
31535
31779
  onMouseLeave: handleMouseLeave,
31536
31780
  children: [
31537
- renderTrigger ? renderTrigger({
31538
- onMouseEnter: handleMouseEnter,
31539
- onMouseLeave: handleMouseLeave,
31540
- address,
31541
- username,
31542
- avatarUrl
31543
- }) : /* @__PURE__ */ jsxDEV3("button", {
31544
- type: "button",
31545
- style: { ...styles2.trigger, ...style },
31546
- "aria-label": "Open account menu",
31547
- children: avatarUrl ? /* @__PURE__ */ jsxDEV3("img", {
31548
- src: avatarUrl,
31549
- alt: "Avatar",
31550
- style: styles2.avatar
31551
- }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV3("div", {
31552
- style: styles2.avatarPlaceholder,
31553
- children: /* @__PURE__ */ jsxDEV3(UserIcon, {
31554
- size: 24,
31555
- color: "#9ca3af"
31556
- }, undefined, false, undefined, this)
31557
- }, undefined, false, undefined, this)
31558
- }, undefined, false, undefined, this),
31781
+ triggerElement,
31559
31782
  isOpen && /* @__PURE__ */ jsxDEV3("div", {
31560
31783
  style: {
31561
31784
  ...styles2.popoverBase,
31562
- ...showAbove ? { bottom: `calc(100% + ${POPOVER_GAP2}px)` } : { top: `calc(100% + ${POPOVER_GAP2}px)` }
31785
+ ...showAbove ? { bottom: `calc(100% + ${POPOVER_GAP}px)` } : { top: `calc(100% + ${POPOVER_GAP}px)` }
31563
31786
  },
31564
31787
  children: [
31565
31788
  /* @__PURE__ */ jsxDEV3("div", {
31566
- style: styles2.section,
31789
+ style: styles2.header,
31567
31790
  children: [
31568
31791
  username && /* @__PURE__ */ jsxDEV3("div", {
31569
- style: styles2.username,
31792
+ style: styles2.headerUsername,
31570
31793
  children: username
31571
31794
  }, undefined, false, undefined, this),
31572
- /* @__PURE__ */ jsxDEV3("div", {
31795
+ address && /* @__PURE__ */ jsxDEV3("div", {
31573
31796
  style: styles2.addressRow,
31574
31797
  children: /* @__PURE__ */ jsxDEV3("button", {
31575
31798
  type: "button",
31576
- onClick: copyToClipboard,
31799
+ onClick: () => void copyToClipboard(),
31577
31800
  style: styles2.addressButton,
31578
31801
  children: /* @__PURE__ */ jsxDEV3("div", {
31579
31802
  style: {
@@ -31585,20 +31808,26 @@ function RenownUserButton({
31585
31808
  },
31586
31809
  children: [
31587
31810
  /* @__PURE__ */ jsxDEV3("div", {
31588
- style: { ...styles2.addressText, opacity: isCopied ? 0 : 1 },
31811
+ style: {
31812
+ ...styles2.addressText,
31813
+ opacity: isCopied ? 0 : 1
31814
+ },
31589
31815
  children: [
31590
31816
  /* @__PURE__ */ jsxDEV3("span", {
31591
- children: truncateAddress(address)
31817
+ children: truncateAddress2(address)
31592
31818
  }, undefined, false, undefined, this),
31593
31819
  /* @__PURE__ */ jsxDEV3(CopyIcon, {
31594
- size: 14,
31595
- color: "#9EA0A1"
31820
+ size: 12,
31821
+ color: "#9ca3af"
31596
31822
  }, undefined, false, undefined, this)
31597
31823
  ]
31598
31824
  }, undefined, true, undefined, this),
31599
31825
  /* @__PURE__ */ jsxDEV3("div", {
31600
- style: { ...styles2.copiedText, opacity: isCopied ? 1 : 0 },
31601
- children: "Copied to clipboard!"
31826
+ style: {
31827
+ ...styles2.copiedText,
31828
+ opacity: isCopied ? 1 : 0
31829
+ },
31830
+ children: "Copied!"
31602
31831
  }, undefined, false, undefined, this)
31603
31832
  ]
31604
31833
  }, undefined, true, undefined, this)
@@ -31606,35 +31835,64 @@ function RenownUserButton({
31606
31835
  }, undefined, false, undefined, this)
31607
31836
  ]
31608
31837
  }, undefined, true, undefined, this),
31609
- userId && /* @__PURE__ */ jsxDEV3("div", {
31610
- style: styles2.section,
31611
- children: /* @__PURE__ */ jsxDEV3("button", {
31612
- type: "button",
31613
- onClick: () => openRenown(userId),
31614
- style: styles2.menuItem,
31615
- children: [
31616
- /* @__PURE__ */ jsxDEV3(ExternalLinkIcon, {
31617
- size: 14
31618
- }, undefined, false, undefined, this),
31619
- "View on Renown"
31620
- ]
31621
- }, undefined, true, undefined, this)
31838
+ /* @__PURE__ */ jsxDEV3("div", {
31839
+ style: styles2.menuSection,
31840
+ children: [
31841
+ profileId && /* @__PURE__ */ jsxDEV3("button", {
31842
+ type: "button",
31843
+ onClick: () => openRenown(profileId),
31844
+ onMouseEnter: () => setHoveredItem("profile"),
31845
+ onMouseLeave: () => setHoveredItem(null),
31846
+ style: {
31847
+ ...styles2.menuItem,
31848
+ ...hoveredItem === "profile" ? styles2.menuItemHover : {}
31849
+ },
31850
+ children: [
31851
+ /* @__PURE__ */ jsxDEV3(UserIcon, {
31852
+ size: 14,
31853
+ color: "#6b7280"
31854
+ }, undefined, false, undefined, this),
31855
+ "View Profile"
31856
+ ]
31857
+ }, undefined, true, undefined, this),
31858
+ menuItems?.map((item) => /* @__PURE__ */ jsxDEV3("button", {
31859
+ type: "button",
31860
+ onClick: item.onClick,
31861
+ onMouseEnter: () => setHoveredItem(item.label),
31862
+ onMouseLeave: () => setHoveredItem(null),
31863
+ style: {
31864
+ ...styles2.menuItem,
31865
+ ...hoveredItem === item.label ? styles2.menuItemHover : {},
31866
+ ...item.style
31867
+ },
31868
+ children: [
31869
+ item.icon,
31870
+ item.label
31871
+ ]
31872
+ }, item.label, true, undefined, this))
31873
+ ]
31874
+ }, undefined, true, undefined, this),
31875
+ /* @__PURE__ */ jsxDEV3("hr", {
31876
+ style: styles2.separator
31622
31877
  }, undefined, false, undefined, this),
31623
31878
  /* @__PURE__ */ jsxDEV3("div", {
31624
- style: styles2.sectionLast,
31879
+ style: styles2.menuSection,
31625
31880
  children: /* @__PURE__ */ jsxDEV3("button", {
31626
31881
  type: "button",
31627
31882
  onClick: onDisconnect,
31883
+ onMouseEnter: () => setHoveredItem("disconnect"),
31884
+ onMouseLeave: () => setHoveredItem(null),
31628
31885
  style: {
31629
31886
  ...styles2.menuItem,
31630
- ...styles2.disconnectItem
31887
+ ...styles2.disconnectItem,
31888
+ ...hoveredItem === "disconnect" ? styles2.menuItemHover : {}
31631
31889
  },
31632
31890
  children: [
31633
31891
  /* @__PURE__ */ jsxDEV3(DisconnectIcon, {
31634
31892
  size: 14,
31635
- color: "#EA4335"
31893
+ color: "#dc2626"
31636
31894
  }, undefined, false, undefined, this),
31637
- "Disconnect"
31895
+ "Log out"
31638
31896
  ]
31639
31897
  }, undefined, true, undefined, this)
31640
31898
  }, undefined, false, undefined, this)
@@ -31645,26 +31903,26 @@ function RenownUserButton({
31645
31903
  }
31646
31904
 
31647
31905
  // src/renown/components/RenownAuthButton.tsx
31648
- import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
31906
+ import { jsxDEV as jsxDEV4, Fragment } from "react/jsx-dev-runtime";
31649
31907
  function RenownAuthButton({
31650
31908
  className = "",
31651
- renderAuthenticated,
31652
- renderUnauthenticated,
31653
- renderLoading
31909
+ darkMode,
31910
+ loginContent,
31911
+ userContent,
31912
+ loadingContent,
31913
+ children
31654
31914
  }) {
31655
- const user = useUser();
31656
- const loginStatus = useLoginStatus();
31657
- const isLoading = loginStatus === "checking";
31658
- const openProfile = () => {
31659
- if (!user)
31660
- return;
31661
- openRenown(user.profile?.documentId);
31662
- };
31663
- if (isLoading) {
31664
- if (renderLoading) {
31915
+ const auth = useRenownAuth();
31916
+ if (children) {
31917
+ return /* @__PURE__ */ jsxDEV4(Fragment, {
31918
+ children: children(auth)
31919
+ }, undefined, false, undefined, this);
31920
+ }
31921
+ if (auth.status === "loading" || auth.status === "checking") {
31922
+ if (loadingContent) {
31665
31923
  return /* @__PURE__ */ jsxDEV4("div", {
31666
31924
  className,
31667
- children: renderLoading()
31925
+ children: loadingContent
31668
31926
  }, undefined, false, undefined, this);
31669
31927
  }
31670
31928
  return /* @__PURE__ */ jsxDEV4("div", {
@@ -31672,24 +31930,44 @@ function RenownAuthButton({
31672
31930
  children: [
31673
31931
  /* @__PURE__ */ jsxDEV4("div", {
31674
31932
  style: {
31675
- width: "40px",
31676
- height: "40px",
31677
- borderRadius: "50%",
31678
- backgroundColor: "#e5e7eb",
31933
+ display: "flex",
31934
+ alignItems: "center",
31935
+ gap: "8px",
31936
+ padding: "6px 12px",
31937
+ borderRadius: "8px",
31938
+ border: "1px solid #e5e7eb",
31679
31939
  animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"
31680
- }
31681
- }, undefined, false, undefined, this),
31940
+ },
31941
+ children: [
31942
+ /* @__PURE__ */ jsxDEV4("div", {
31943
+ style: {
31944
+ width: "28px",
31945
+ height: "28px",
31946
+ borderRadius: "50%",
31947
+ backgroundColor: "#e5e7eb"
31948
+ }
31949
+ }, undefined, false, undefined, this),
31950
+ /* @__PURE__ */ jsxDEV4("div", {
31951
+ style: {
31952
+ width: "80px",
31953
+ height: "14px",
31954
+ borderRadius: "4px",
31955
+ backgroundColor: "#e5e7eb"
31956
+ }
31957
+ }, undefined, false, undefined, this)
31958
+ ]
31959
+ }, undefined, true, undefined, this),
31682
31960
  /* @__PURE__ */ jsxDEV4("style", {
31683
31961
  children: `@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }`
31684
31962
  }, undefined, false, undefined, this)
31685
31963
  ]
31686
31964
  }, undefined, true, undefined, this);
31687
31965
  }
31688
- if (loginStatus === "authorized" && user) {
31689
- if (renderAuthenticated) {
31966
+ if (auth.status === "authorized") {
31967
+ if (userContent) {
31690
31968
  return /* @__PURE__ */ jsxDEV4("div", {
31691
31969
  className,
31692
- children: renderAuthenticated({ user, logout, openProfile })
31970
+ children: userContent
31693
31971
  }, undefined, false, undefined, this);
31694
31972
  }
31695
31973
  return /* @__PURE__ */ jsxDEV4("div", {
@@ -31697,62 +31975,63 @@ function RenownAuthButton({
31697
31975
  children: /* @__PURE__ */ jsxDEV4(RenownUserButton, {}, undefined, false, undefined, this)
31698
31976
  }, undefined, false, undefined, this);
31699
31977
  }
31700
- if (renderUnauthenticated) {
31978
+ if (loginContent) {
31701
31979
  return /* @__PURE__ */ jsxDEV4("div", {
31702
31980
  className,
31703
- children: renderUnauthenticated({ openRenown: () => openRenown(), isLoading })
31981
+ children: loginContent
31704
31982
  }, undefined, false, undefined, this);
31705
31983
  }
31706
31984
  return /* @__PURE__ */ jsxDEV4("div", {
31707
31985
  className,
31708
- children: /* @__PURE__ */ jsxDEV4(RenownLoginButton, {}, undefined, false, undefined, this)
31986
+ children: /* @__PURE__ */ jsxDEV4(RenownLoginButton, {
31987
+ darkMode
31988
+ }, undefined, false, undefined, this)
31709
31989
  }, undefined, false, undefined, this);
31710
31990
  }
31711
- // src/renown/provider.tsx
31712
- import { useEffect as useEffect9, useRef as useRef7 } from "react";
31713
- function RenownProvider({
31991
+ // src/renown/use-renown-init.ts
31992
+ import { useRef as useRef6 } from "react";
31993
+ async function initRenown(appName, namespace, url) {
31994
+ addRenownEventHandler();
31995
+ setRenown(loading);
31996
+ const builder = new RenownBuilder(appName, {
31997
+ basename: namespace,
31998
+ baseUrl: url
31999
+ });
32000
+ const renown = await builder.build();
32001
+ setRenown(renown);
32002
+ await login(undefined, renown);
32003
+ return renown;
32004
+ }
32005
+ function useRenownInit({
31714
32006
  appName,
31715
- basename,
31716
- baseUrl,
31717
- children
32007
+ namespace,
32008
+ url
31718
32009
  }) {
31719
- const initRef = useRef7(false);
31720
- const initialPropsRef = useRef7({ appName, basename, baseUrl });
32010
+ const promiseRef = useRef6(Promise.withResolvers());
32011
+ const initRef = useRef6(false);
32012
+ if (typeof window === "undefined") {
32013
+ promiseRef.current.reject(new Error("window is undefined"));
32014
+ return promiseRef.current.promise;
32015
+ }
31721
32016
  if (initRef.current) {
31722
- const initial = initialPropsRef.current;
31723
- if (appName !== initial.appName) {
31724
- console.warn("RenownProvider: 'appName' changed after mount. This prop is only read once during initialization.");
31725
- }
31726
- if (basename !== initial.basename) {
31727
- console.warn("RenownProvider: 'basename' changed after mount. This prop is only read once during initialization.");
31728
- }
31729
- if (baseUrl !== initial.baseUrl) {
31730
- console.warn("RenownProvider: 'baseUrl' changed after mount. This prop is only read once during initialization.");
31731
- }
32017
+ return promiseRef.current.promise;
31732
32018
  }
31733
- useEffect9(() => {
31734
- if (initRef.current)
31735
- return;
31736
- initRef.current = true;
31737
- if (!window.ph) {
31738
- window.ph = {};
31739
- }
31740
- addRenownEventHandler();
31741
- const init = async () => {
31742
- const builder = new RenownBuilder(appName, { basename, baseUrl });
31743
- const instance = await builder.build();
31744
- setRenown(instance);
31745
- await login(undefined, instance);
31746
- };
31747
- init().catch(console.error);
31748
- }, []);
31749
- return children;
32019
+ initRef.current = true;
32020
+ initRenown(appName, namespace, url).then(promiseRef.current.resolve).catch(promiseRef.current.reject);
32021
+ return promiseRef.current.promise;
32022
+ }
32023
+
32024
+ // src/renown/renown-init.tsx
32025
+ function Renown2({ onError, ...initOptions }) {
32026
+ useRenownInit(initOptions).catch(onError ?? console.error);
32027
+ return null;
31750
32028
  }
31751
32029
  export {
31752
32030
  validateDocument,
31753
32031
  useVetraPackages,
31754
32032
  useVetraPackageManager,
31755
32033
  useUserPermissions,
32034
+ useUser,
31756
32035
  useSupportedDocumentTypesInReactor,
31757
32036
  useSubgraphModules,
31758
32037
  useSetPHDriveEditorConfig,
@@ -31771,8 +32050,12 @@ export {
31771
32050
  useSelectedDocumentId,
31772
32051
  useSelectedDocument,
31773
32052
  useRevisionHistoryVisible,
32053
+ useRenownInit,
32054
+ useRenownAuth,
32055
+ useRenown,
31774
32056
  useRelationalQuery,
31775
32057
  useRelationalDb,
32058
+ usePendingInstallations,
31776
32059
  useParentFolderForSelectedNode,
31777
32060
  usePHToast,
31778
32061
  usePHModal,
@@ -31788,6 +32071,8 @@ export {
31788
32071
  useNodeParentFolderById,
31789
32072
  useNodeById,
31790
32073
  useNodeActions,
32074
+ useLoginStatus,
32075
+ useLoading,
31791
32076
  useIsExternalControlsEnabled,
31792
32077
  useIsDragAndDropEnabled,
31793
32078
  useInspectorEnabled,
@@ -31823,6 +32108,8 @@ export {
31823
32108
  useDocumentCache,
31824
32109
  useDocumentById,
31825
32110
  useDocument,
32111
+ useDismissedPackages,
32112
+ useDid,
31826
32113
  useDefaultDriveEditorModule,
31827
32114
  useConnectionStates,
31828
32115
  useConnectionState,
@@ -31847,6 +32134,7 @@ export {
31847
32134
  setPHDriveEditorConfig,
31848
32135
  setPHDocumentEditorConfigByKey,
31849
32136
  setPHDocumentEditorConfig,
32137
+ setLoading,
31850
32138
  setGlobal,
31851
32139
  setFeatures,
31852
32140
  setDriveSharingType,
@@ -31866,6 +32154,7 @@ export {
31866
32154
  makeDriveUrlComponent,
31867
32155
  logout,
31868
32156
  login,
32157
+ loading,
31869
32158
  isInspectorEnabledSync,
31870
32159
  isFolderNodeKind,
31871
32160
  isFileNodeKind,
@@ -31914,6 +32203,7 @@ export {
31914
32203
  baseDocumentModelsMap,
31915
32204
  baseDocumentModels,
31916
32205
  addTrigger,
32206
+ addRenownEventHandler,
31917
32207
  addRemoteDrive,
31918
32208
  addPromiseState,
31919
32209
  addFolder,
@@ -31925,10 +32215,10 @@ export {
31925
32215
  SyncOperationStatus,
31926
32216
  SpinnerIcon,
31927
32217
  RenownUserButton,
31928
- RenownProvider,
31929
32218
  RenownLogo,
31930
32219
  RenownLoginButton,
31931
32220
  RenownAuthButton,
32221
+ Renown2 as Renown,
31932
32222
  RemoteDocumentController,
31933
32223
  RemoteClient,
31934
32224
  RelationalDbProcessor,
@@ -31946,7 +32236,6 @@ export {
31946
32236
  InMemoryQueue,
31947
32237
  ISSUER_TYPE,
31948
32238
  GqlRequestChannel2 as GqlRequestChannel,
31949
- ExternalLinkIcon,
31950
32239
  DocumentChangeType,
31951
32240
  DocumentCache,
31952
32241
  DisconnectIcon,
@@ -31955,6 +32244,7 @@ export {
31955
32244
  CopyIcon,
31956
32245
  ConsoleLogger,
31957
32246
  ConflictError,
32247
+ ChevronDownIcon,
31958
32248
  ChannelScheme,
31959
32249
  CREDENTIAL_TYPES,
31960
32250
  CREDENTIAL_SUBJECT_TYPE,