@aomi-labs/react 0.3.8 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,15 +10,15 @@ npm install @aomi-labs/react @assistant-ui/react react react-dom
10
10
  pnpm add @aomi-labs/react @assistant-ui/react react react-dom
11
11
  ```
12
12
 
13
- Optional dependencies for advanced custom wallet adapters:
13
+ Optional dependencies when wiring wallet UI through Para + wagmi:
14
14
 
15
15
  ```bash
16
16
  pnpm add wagmi viem
17
17
  ```
18
18
 
19
- If you use the registry-installed `AomiFrame`, the default Para-backed
20
- `AomiAdapterProvider` is already wired for you. Add `wagmi` only when you want
21
- to bring your own adapter implementation.
19
+ If you use the registry-installed `AomiFrame` from `@aomi-labs/widget-lib`,
20
+ wallet behavior comes from the surrounding Para + wagmi provider tree.
21
+ `@aomi-labs/react` does not ship built-in wallet providers.
22
22
 
23
23
  ## Quick Start
24
24
 
package/dist/index.cjs CHANGED
@@ -897,6 +897,16 @@ function useCurrentThreadMetadata() {
897
897
  var import_react5 = require("react");
898
898
  var import_jsx_runtime5 = require("react/jsx-runtime");
899
899
  var UserContext = (0, import_react5.createContext)(void 0);
900
+ function normalizeUserState(next, data) {
901
+ if (data.isConnected === false) {
902
+ return __spreadProps(__spreadValues({}, next), {
903
+ address: void 0,
904
+ chainId: void 0,
905
+ ensName: void 0
906
+ });
907
+ }
908
+ return next;
909
+ }
900
910
  function useUser() {
901
911
  const context = (0, import_react5.useContext)(UserContext);
902
912
  if (!context) {
@@ -926,7 +936,7 @@ function UserContextProvider({ children }) {
926
936
  );
927
937
  const setUser = (0, import_react5.useCallback)((data) => {
928
938
  setUserState((prev) => {
929
- const next = __spreadValues(__spreadValues({}, prev), data);
939
+ const next = normalizeUserState(__spreadValues(__spreadValues({}, prev), data), data);
930
940
  StateChangeCallbacks.current.forEach((callback) => {
931
941
  callback(next);
932
942
  });
@@ -1520,7 +1530,11 @@ function AomiRuntimeCore({
1520
1530
  cancelGeneration: orchestratorCancel,
1521
1531
  aomiClientRef
1522
1532
  } = useRuntimeOrchestrator(aomiClient, {
1523
- getPublicKey: () => getUserState().address,
1533
+ getPublicKey: () => {
1534
+ var _a;
1535
+ const userState = getUserState();
1536
+ return userState.isConnected ? (_a = userState.address) != null ? _a : void 0 : void 0;
1537
+ },
1524
1538
  getUserState,
1525
1539
  getApp: getCurrentThreadApp,
1526
1540
  getApiKey: () => getControlState().apiKey,
@@ -1603,7 +1617,7 @@ function AomiRuntimeCore({
1603
1617
  threadContext.currentThreadId
1604
1618
  );
1605
1619
  (0, import_react9.useEffect)(() => {
1606
- const userAddress = user.address;
1620
+ const userAddress = user.isConnected ? user.address : void 0;
1607
1621
  if (!userAddress) return;
1608
1622
  const fetchThreadList = async () => {
1609
1623
  var _a, _b, _c;
@@ -1640,7 +1654,7 @@ function AomiRuntimeCore({
1640
1654
  }
1641
1655
  };
1642
1656
  void fetchThreadList();
1643
- }, [user.address, aomiClientRef]);
1657
+ }, [user.address, user.isConnected, aomiClientRef]);
1644
1658
  const threadListAdapter = (0, import_react9.useMemo)(
1645
1659
  () => buildThreadListAdapter({
1646
1660
  aomiClientRef,
@@ -1843,7 +1857,7 @@ function AomiRuntimeInner({
1843
1857
  {
1844
1858
  aomiClient,
1845
1859
  sessionId: threadContext.currentThreadId,
1846
- publicKey: (_a = user.address) != null ? _a : void 0,
1860
+ publicKey: user.isConnected ? (_a = user.address) != null ? _a : void 0 : void 0,
1847
1861
  getThreadMetadata: threadContext.getThreadMetadata,
1848
1862
  updateThreadMetadata: threadContext.updateThreadMetadata,
1849
1863
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(