hyperstack-react 0.3.15 → 0.4.1

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.d.ts CHANGED
@@ -4,10 +4,6 @@ export { AccountCategory, AccountMeta, AccountResolutionOptions, AccountResoluti
4
4
  import { UseBoundStore, StoreApi } from 'zustand';
5
5
 
6
6
  type ViewMode = 'state' | 'list';
7
- interface NetworkConfig {
8
- name: string;
9
- websocketUrl: string;
10
- }
11
7
  interface TransactionDefinition<TParams = unknown> {
12
8
  build: (params: TParams) => {
13
9
  instruction: string;
@@ -18,10 +14,14 @@ interface TransactionDefinition<TParams = unknown> {
18
14
  key?: string | ((params: TParams) => string);
19
15
  }>;
20
16
  }
17
+ /**
18
+ * Global configuration for HyperstackProvider.
19
+ *
20
+ * Note: WebSocket URL is no longer configured here. The URL is:
21
+ * 1. Embedded in the stack definition (stack.url)
22
+ * 2. Optionally overridden per-hook via useHyperstack(stack, { url: '...' })
23
+ */
21
24
  interface HyperstackConfig {
22
- websocketUrl?: string;
23
- network?: 'devnet' | 'mainnet' | 'localnet' | NetworkConfig;
24
- apiKey?: string;
25
25
  autoConnect?: boolean;
26
26
  wallet?: WalletAdapter;
27
27
  reconnectIntervals?: number[];
@@ -29,6 +29,13 @@ interface HyperstackConfig {
29
29
  maxEntriesPerView?: number | null;
30
30
  flushIntervalMs?: number;
31
31
  }
32
+ /**
33
+ * Options for useHyperstack hook
34
+ */
35
+ interface UseHyperstackOptions {
36
+ /** Override the stack's embedded URL (useful for local development) */
37
+ url?: string;
38
+ }
32
39
  interface ViewHookOptions {
33
40
  enabled?: boolean;
34
41
  initialData?: unknown;
@@ -73,15 +80,9 @@ interface ListViewHook<T> {
73
80
  }
74
81
 
75
82
  interface HyperstackContextValue {
76
- getOrCreateClient: <TStack extends StackDefinition>(stack: TStack) => Promise<HyperStack<TStack>>;
83
+ getOrCreateClient: <TStack extends StackDefinition>(stack: TStack, urlOverride?: string) => Promise<HyperStack<TStack>>;
77
84
  getClient: <TStack extends StackDefinition>(stack: TStack | undefined) => HyperStack<TStack> | null;
78
- config: {
79
- websocketUrl: string;
80
- autoConnect?: boolean;
81
- reconnectIntervals?: number[];
82
- maxReconnectAttempts?: number;
83
- maxEntriesPerView?: number | null;
84
- };
85
+ config: HyperstackConfig;
85
86
  }
86
87
  declare function HyperstackProvider({ children, fallback, ...config }: HyperstackConfig & {
87
88
  children: ReactNode;
@@ -109,7 +110,6 @@ declare function useInstructionMutation(execute: InstructionExecutor): UseMutati
109
110
 
110
111
  interface ZustandState {
111
112
  entities: Map<string, Map<string, unknown>>;
112
- sortedKeys: Map<string, string[]>;
113
113
  viewConfigs: Map<string, ViewSortConfig>;
114
114
  connectionState: ConnectionState;
115
115
  lastError?: string;
@@ -120,7 +120,6 @@ interface ZustandActions {
120
120
  _clear: (viewPath?: string) => void;
121
121
  _setConnectionState: (state: ConnectionState, error?: string) => void;
122
122
  _setViewConfig: (viewPath: string, config: ViewSortConfig) => void;
123
- _updateSortedKeys: (viewPath: string, sortedKeys: string[]) => void;
124
123
  }
125
124
  type HyperStackStore = ZustandState & ZustandActions;
126
125
  declare class ZustandAdapter implements StorageAdapter {
@@ -147,7 +146,6 @@ declare class ZustandAdapter implements StorageAdapter {
147
146
  setConnectionState(state: ConnectionState, error?: string): void;
148
147
  setViewConfig(viewPath: string, config: ViewSortConfig): void;
149
148
  getViewConfig(viewPath: string): ViewSortConfig | undefined;
150
- private rebuildSortedKeys;
151
149
  }
152
150
 
153
151
  type ViewHookForDef<TDef> = TDef extends ViewDef<infer T, 'state'> ? {
@@ -185,7 +183,7 @@ type StackClient<TStack extends StackDefinition> = {
185
183
  isLoading: boolean;
186
184
  error: Error | null;
187
185
  };
188
- declare function useHyperstack<TStack extends StackDefinition>(stack: TStack): StackClient<TStack>;
186
+ declare function useHyperstack<TStack extends StackDefinition>(stack: TStack, options?: UseHyperstackOptions): StackClient<TStack>;
189
187
 
190
188
  export { HyperstackProvider, ZustandAdapter, useConnectionState, useEntity, useHyperstack, useHyperstackContext, useInstructionMutation, useView };
191
- export type { HyperStackStore, HyperstackConfig, ListParams, ListParamsBase, ListParamsMultiple, ListParamsSingle, ListViewHook, MutationStatus, NetworkConfig, StateViewHook, TransactionDefinition, UseMutationOptions, UseMutationResult, UseMutationReturn, ViewHookOptions, ViewHookResult, ViewMode };
189
+ export type { HyperStackStore, HyperstackConfig, ListParams, ListParamsBase, ListParamsMultiple, ListParamsSingle, ListViewHook, MutationStatus, StateViewHook, TransactionDefinition, UseHyperstackOptions, UseMutationOptions, UseMutationResult, UseMutationReturn, ViewHookOptions, ViewHookResult, ViewMode };