@molecule/app-react-native 1.0.0

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 ADDED
@@ -0,0 +1,2666 @@
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-08-04T00:40:53.854Z
7
+ -->
8
+
9
+ # @molecule/app-react-native
10
+
11
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
+ > It is written to be read by coding agents as much as by people, and is generated from this
13
+ > package's source — edit `src/index.ts` JSDoc, not this file.
14
+
15
+ React Native framework bindings for molecule.dev.
16
+
17
+ Re-exports every hook and provider from `@molecule/app-react` (they are pure
18
+ React — no DOM dependency) and adds RN-specific hooks: `useAppState`
19
+ (foreground/background), `useBackHandler` (Android back button),
20
+ `useKeyboardHeight`, and `useSafeArea`.
21
+
22
+ ## Quick Start
23
+
24
+ ```tsx
25
+ import { MoleculeProvider, useAuth, useAppState, useSafeArea } from '@molecule/app-react-native'
26
+ import { SafeAreaProvider } from 'react-native-safe-area-context'
27
+ import { View } from 'react-native'
28
+ import { provider as stateProvider } from '@molecule/app-state-zustand'
29
+ import { createJWTAuthClient } from '@molecule/app-auth'
30
+
31
+ const authClient = createJWTAuthClient({ baseURL: 'https://api.example.com' })
32
+
33
+ function Shell() {
34
+ const { isAuthenticated } = useAuth()
35
+ const { isActive } = useAppState()
36
+ const insets = useSafeArea()
37
+ return (
38
+ <View style={{ paddingTop: insets.top }}>{isAuthenticated && isActive ? <View /> : null}</View>
39
+ )
40
+ }
41
+
42
+ function App() {
43
+ return (
44
+ <SafeAreaProvider>
45
+ <MoleculeProvider state={stateProvider} auth={authClient}>
46
+ <Shell />
47
+ </MoleculeProvider>
48
+ </SafeAreaProvider>
49
+ )
50
+ }
51
+ ```
52
+
53
+ ## Type
54
+
55
+ `framework`
56
+
57
+ ## Installation
58
+
59
+ ```bash
60
+ npm install @molecule/app-react-native @molecule/app-keyboard @molecule/app-lifecycle @molecule/app-react react react-native react-native-safe-area-context
61
+ ```
62
+
63
+ ## API
64
+
65
+ ### Interfaces
66
+
67
+ #### `AgentIdentity`
68
+
69
+ Display identity for the AI coding agent and the host product, used to
70
+ interpolate the `{{agentName}}` / `{{productName}}` tokens in shared chat/IDE
71
+ copy. A consuming app sets these to its own agent + product brand names; the
72
+ shared packages fall back to {@link DEFAULT_AGENT_IDENTITY} when it does not.
73
+
74
+ ```typescript
75
+ interface AgentIdentity {
76
+ /** Display name of the AI coding agent. Defaults to {@link DEFAULT_AGENT_NAME}. */
77
+ agentName: string
78
+ /** Display name of the host product / IDE. Defaults to {@link DEFAULT_PRODUCT_NAME}. */
79
+ productName: string
80
+ }
81
+ ```
82
+
83
+ #### `AuthClient`
84
+
85
+ Auth client interface that all auth bond packages must implement.
86
+ Provides login/logout/register flows, token management, profile
87
+ updates, and auth state subscription.
88
+
89
+ ```typescript
90
+ interface AuthClient<T = UserProfile> {
91
+ /**
92
+ * Returns the current authentication state snapshot.
93
+ */
94
+ getState(): AuthState<T>
95
+ /**
96
+ * Returns whether the user is currently authenticated.
97
+ */
98
+ isAuthenticated(): boolean
99
+ /**
100
+ * Gets the current user.
101
+ */
102
+ getUser(): T | null
103
+ /**
104
+ * Updates the cached user object (state + persistent storage) without
105
+ * hitting the network. Intended for local refreshes after a per-app
106
+ * mutation (e.g., the user just PATCHed their own profile and the
107
+ * server returned the canonical row). Does NOT change tokens.
108
+ */
109
+ setUser(user: T | null): void
110
+ /**
111
+ * Gets the current access token.
112
+ */
113
+ getAccessToken(): string | null
114
+ /**
115
+ * Stores the access token in the configured token storage adapter (in-memory
116
+ * by default). Use this to seed the token after an out-of-band exchange (e.g.
117
+ * the OAuth code→token redirect) instead of writing to `localStorage` directly,
118
+ * which would violate the in-memory-default storage contract and make the bearer
119
+ * token JS-readable (XSS-exfiltratable). Pass `null` to clear it.
120
+ */
121
+ setAccessToken(token: string | null): void
122
+ /**
123
+ * Gets the refresh token.
124
+ */
125
+ getRefreshToken(): string | null
126
+ /**
127
+ * Logs in with credentials.
128
+ */
129
+ login(credentials: LoginCredentials): Promise<AuthResult<T>>
130
+ /**
131
+ * Logs out the current user.
132
+ */
133
+ logout(): Promise<void>
134
+ /**
135
+ * Registers a new user.
136
+ */
137
+ register(data: RegisterData): Promise<AuthResult<T>>
138
+ /**
139
+ * Refreshes the access token.
140
+ */
141
+ refresh(): Promise<AuthResult<T>>
142
+ /**
143
+ * Requests a password reset.
144
+ */
145
+ requestPasswordReset(data: PasswordResetRequest): Promise<void>
146
+ /**
147
+ * Confirms a password reset.
148
+ */
149
+ confirmPasswordReset(data: PasswordResetConfirm): Promise<void>
150
+ /**
151
+ * Updates the current user's profile.
152
+ */
153
+ updateProfile(data: Partial<T>): Promise<T>
154
+ /**
155
+ * Changes the current user's password.
156
+ */
157
+ changePassword(oldPassword: string, newPassword: string): Promise<void>
158
+ /**
159
+ * Initializes auth state (e.g., from stored tokens).
160
+ */
161
+ initialize(): Promise<void>
162
+ /**
163
+ * Subscribes to auth state changes.
164
+ */
165
+ subscribe(callback: (state: AuthState<T>) => void): () => void
166
+ /**
167
+ * Subscribes to auth state changes (alias for subscribe).
168
+ */
169
+ onAuthChange(callback: (state: AuthState<T>) => void): () => void
170
+ /**
171
+ * Gets the current access token (alias for getAccessToken).
172
+ */
173
+ getToken?(): string | null
174
+ /**
175
+ * Adds an auth event listener.
176
+ */
177
+ addEventListener(listener: AuthEventListener): () => void
178
+ /**
179
+ * Destroys the auth client.
180
+ */
181
+ destroy(): void
182
+ }
183
+ ```
184
+
185
+ #### `AuthProviderProps`
186
+
187
+ Props for auth provider component.
188
+
189
+ ```typescript
190
+ interface AuthProviderProps<T = unknown> extends ProviderProps {
191
+ client: AuthClient<T>
192
+ }
193
+ ```
194
+
195
+ #### `AuthState`
196
+
197
+ Reactive authentication state snapshot (initialized, authenticated, user, loading, and error).
198
+
199
+ ```typescript
200
+ interface AuthState<T = UserProfile> {
201
+ /**
202
+ * Whether auth state has been initialized.
203
+ */
204
+ initialized: boolean
205
+ /**
206
+ * Whether the user is authenticated.
207
+ */
208
+ authenticated: boolean
209
+ /**
210
+ * Current user (if authenticated).
211
+ */
212
+ user: T | null
213
+ /**
214
+ * Whether an auth operation is in progress.
215
+ */
216
+ loading: boolean
217
+ /**
218
+ * Last auth error (if any).
219
+ */
220
+ error: string | null
221
+ }
222
+ ```
223
+
224
+ #### `ChatProviderProps`
225
+
226
+ Props for the ChatProvider React component.
227
+
228
+ ```typescript
229
+ interface ChatProviderProps extends ProviderProps {
230
+ provider: ChatProvider
231
+ }
232
+ ```
233
+
234
+ #### `EditorProviderProps`
235
+
236
+ Props for editor provider component.
237
+
238
+ ```typescript
239
+ interface EditorProviderProps extends ProviderProps {
240
+ provider: EditorProvider
241
+ }
242
+ ```
243
+
244
+ #### `FormController`
245
+
246
+ Form controller interface.
247
+
248
+ All form providers must implement this interface.
249
+
250
+ ```typescript
251
+ interface FormController<T extends Record<string, unknown> = Record<string, unknown>> {
252
+ /**
253
+ * Gets the current form state.
254
+ */
255
+ getState(): FormState<T>
256
+ /**
257
+ * Gets the value of a specific field.
258
+ */
259
+ getValue(name: string): unknown
260
+ getValue<K extends keyof T>(name: K): T[K]
261
+ /**
262
+ * Gets all form values.
263
+ */
264
+ getValues(): T
265
+ /**
266
+ * Sets the value of a specific field.
267
+ */
268
+ setValue(
269
+ name: string,
270
+ value: unknown,
271
+ options?: {
272
+ shouldValidate?: boolean
273
+ shouldDirty?: boolean
274
+ shouldTouch?: boolean
275
+ },
276
+ ): void
277
+ /**
278
+ * Sets multiple values at once.
279
+ */
280
+ setValues(
281
+ values: Partial<T>,
282
+ options?: {
283
+ shouldValidate?: boolean
284
+ },
285
+ ): void
286
+ /**
287
+ * Gets the error for a specific field.
288
+ */
289
+ getError(name: string): string | undefined
290
+ /**
291
+ * Sets the error for a specific field.
292
+ */
293
+ setError(name: string, error: string | undefined): void
294
+ /**
295
+ * Clears the error for a specific field.
296
+ */
297
+ clearError<K extends keyof T>(name: K): void
298
+ /**
299
+ * Clears all errors.
300
+ */
301
+ clearErrors(): void
302
+ /**
303
+ * Gets the field state for a specific field.
304
+ */
305
+ getFieldState<K extends keyof T>(name: K): FieldState<T[K]>
306
+ /**
307
+ * Registers a field for form management.
308
+ */
309
+ register(nameOrOptions: string | RegisterOptions, options?: RegisterOptions): FieldRegistration
310
+ /**
311
+ * Unregisters a field.
312
+ */
313
+ unregister(name: string): void
314
+ /**
315
+ * Validates a specific field.
316
+ */
317
+ validateField<K extends keyof T>(name: K): Promise<boolean>
318
+ /**
319
+ * Validates all fields.
320
+ */
321
+ validate(): Promise<boolean>
322
+ /**
323
+ * Resets the form to initial values.
324
+ */
325
+ reset(values?: Partial<T>): void
326
+ /**
327
+ * Handles form submission.
328
+ */
329
+ handleSubmit(
330
+ onSubmit: (values: T) => void | Promise<void>,
331
+ onError?: (errors: Partial<Record<keyof T, string>>) => void,
332
+ ): (event?: { preventDefault?: () => void }) => Promise<void>
333
+ /**
334
+ * Sets focus to a field.
335
+ */
336
+ setFocus(name: keyof T): void
337
+ /**
338
+ * Subscribes to form state changes.
339
+ */
340
+ subscribe(callback: (state: FormState<T>) => void): () => void
341
+ /**
342
+ * Destroys the form controller.
343
+ */
344
+ destroy(): void
345
+ }
346
+ ```
347
+
348
+ #### `FormOptions`
349
+
350
+ Form creation options.
351
+
352
+ ```typescript
353
+ interface FormOptions<T extends Record<string, unknown>> {
354
+ /**
355
+ * Default values.
356
+ */
357
+ defaultValues?: Partial<T>
358
+ /**
359
+ * Validation mode.
360
+ */
361
+ mode?: 'onSubmit' | 'onChange' | 'onBlur' | 'all'
362
+ /**
363
+ * Revalidation mode.
364
+ */
365
+ reValidateMode?: 'onChange' | 'onBlur' | 'onSubmit'
366
+ /**
367
+ * Whether to focus the first error field on submit.
368
+ */
369
+ shouldFocusError?: boolean
370
+ /**
371
+ * Form-level validation function.
372
+ */
373
+ validate?: (
374
+ values: T,
375
+ ) => Partial<Record<keyof T, string>> | Promise<Partial<Record<keyof T, string>>>
376
+ }
377
+ ```
378
+
379
+ #### `HttpClient`
380
+
381
+ HTTP client interface.
382
+
383
+ All HTTP providers must implement this interface.
384
+
385
+ ```typescript
386
+ interface HttpClient {
387
+ /**
388
+ * Base URL for all requests.
389
+ */
390
+ baseURL: string
391
+ /**
392
+ * Default headers for all requests.
393
+ */
394
+ defaultHeaders: Record<string, string>
395
+ /**
396
+ * Makes a generic HTTP request.
397
+ */
398
+ request<T = unknown>(config: FullRequestConfig): Promise<HttpResponse<T>>
399
+ /**
400
+ * Makes a GET request.
401
+ */
402
+ get<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
403
+ /**
404
+ * Makes a POST request.
405
+ */
406
+ post<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
407
+ /**
408
+ * Makes a PUT request.
409
+ */
410
+ put<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
411
+ /**
412
+ * Makes a PATCH request.
413
+ */
414
+ patch<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
415
+ /**
416
+ * Makes a DELETE request.
417
+ */
418
+ delete<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
419
+ /**
420
+ * Adds a request interceptor.
421
+ * Returns a function to remove the interceptor.
422
+ */
423
+ addRequestInterceptor(interceptor: RequestInterceptor): () => void
424
+ /**
425
+ * Adds a response interceptor.
426
+ * Returns a function to remove the interceptor.
427
+ */
428
+ addResponseInterceptor(interceptor: ResponseInterceptor): () => void
429
+ /**
430
+ * Adds an error interceptor.
431
+ * Returns a function to remove the interceptor.
432
+ */
433
+ addErrorInterceptor(interceptor: ErrorInterceptor): () => void
434
+ /**
435
+ * Sets the authorization token.
436
+ */
437
+ setAuthToken(token: string | null): void
438
+ /**
439
+ * Returns the current authorization token, or `null` if not set.
440
+ */
441
+ getAuthToken(): string | null
442
+ /**
443
+ * Registers a handler for authentication errors (401).
444
+ *
445
+ * @returns An unsubscribe function.
446
+ */
447
+ onAuthError(handler: () => void): () => void
448
+ }
449
+ ```
450
+
451
+ #### `HttpProviderProps`
452
+
453
+ Props for http provider component.
454
+
455
+ ```typescript
456
+ interface HttpProviderProps extends ProviderProps {
457
+ client: HttpClient
458
+ }
459
+ ```
460
+
461
+ #### `I18nProviderProps`
462
+
463
+ Props for i18n provider component.
464
+
465
+ ```typescript
466
+ interface I18nProviderProps extends ProviderProps {
467
+ provider: I18nProvider
468
+ }
469
+ ```
470
+
471
+ #### `LoggerProviderProps`
472
+
473
+ Props for logger provider component.
474
+
475
+ ```typescript
476
+ interface LoggerProviderProps extends ProviderProps {
477
+ provider: LoggerProvider
478
+ }
479
+ ```
480
+
481
+ #### `MoleculeProviderProps`
482
+
483
+ Properties for molecule provider.
484
+
485
+ ```typescript
486
+ interface MoleculeProviderProps extends ProviderProps {
487
+ state?: StateProvider
488
+ auth?: AuthClient<unknown>
489
+ theme?: ThemeProvider
490
+ router?: Router
491
+ i18n?: I18nProvider
492
+ http?: HttpClient
493
+ storage?: StorageProvider
494
+ logger?: LoggerProvider
495
+ chat?: ChatProvider
496
+ workspace?: WorkspaceProvider
497
+ editor?: EditorProvider
498
+ preview?: PreviewProvider
499
+ }
500
+ ```
501
+
502
+ #### `PreviewProviderProps`
503
+
504
+ Props for preview provider component.
505
+
506
+ ```typescript
507
+ interface PreviewProviderProps extends ProviderProps {
508
+ provider: PreviewProvider
509
+ }
510
+ ```
511
+
512
+ #### `ProviderProps`
513
+
514
+ Props for provider components.
515
+
516
+ ```typescript
517
+ interface ProviderProps {
518
+ children: ReactNode
519
+ }
520
+ ```
521
+
522
+ #### `Router`
523
+
524
+ Client-side router providing navigation, guards, route matching, and history control.
525
+
526
+ All routing providers must implement this interface.
527
+
528
+ ```typescript
529
+ interface Router {
530
+ /**
531
+ * Returns the current route location (pathname, search, hash, state).
532
+ */
533
+ getLocation(): RouteLocation
534
+ /**
535
+ * Gets the current route params.
536
+ */
537
+ getParams<T extends RouteParams = RouteParams>(): T
538
+ /**
539
+ * Gets the current query params.
540
+ */
541
+ getQuery(): QueryParams
542
+ /**
543
+ * Gets a specific query parameter.
544
+ */
545
+ getQueryParam(key: string): string | undefined
546
+ /**
547
+ * Gets the current hash.
548
+ */
549
+ getHash(): string
550
+ /**
551
+ * Navigates to a path.
552
+ */
553
+ navigate(path: string, options?: NavigateOptions): void
554
+ /**
555
+ * Navigates to a named route.
556
+ */
557
+ navigateTo(
558
+ name: string,
559
+ params?: RouteParams,
560
+ query?: QueryParams,
561
+ options?: NavigateOptions,
562
+ ): void
563
+ /**
564
+ * Goes back in history.
565
+ */
566
+ back(): void
567
+ /**
568
+ * Goes forward in history.
569
+ */
570
+ forward(): void
571
+ /**
572
+ * Goes to a specific point in history.
573
+ */
574
+ go(delta: number): void
575
+ /**
576
+ * Updates the current query params.
577
+ */
578
+ setQuery(params: QueryParams, options?: NavigateOptions): void
579
+ /**
580
+ * Updates a specific query parameter.
581
+ */
582
+ setQueryParam(key: string, value: string | undefined, options?: NavigateOptions): void
583
+ /**
584
+ * Updates the current hash.
585
+ */
586
+ setHash(hash: string, options?: NavigateOptions): void
587
+ /**
588
+ * Checks if a path matches the current location.
589
+ *
590
+ * @returns `true` if the path matches the current route.
591
+ */
592
+ isActive(path: string, exact?: boolean): boolean
593
+ /**
594
+ * Matches a path pattern against a pathname.
595
+ */
596
+ matchPath<Params extends RouteParams = RouteParams>(
597
+ pattern: string,
598
+ pathname: string,
599
+ ): RouteMatch<Params> | null
600
+ /**
601
+ * Generates a URL from a named route.
602
+ */
603
+ generatePath(name: string, params?: RouteParams, query?: QueryParams): string
604
+ /**
605
+ * Subscribes to route changes.
606
+ */
607
+ subscribe(listener: RouteChangeListener): () => void
608
+ /**
609
+ * Adds a navigation guard.
610
+ */
611
+ addGuard(guard: NavigationGuard): () => void
612
+ /**
613
+ * Registers route definitions.
614
+ */
615
+ registerRoutes(routes: RouteDefinition[]): void
616
+ /**
617
+ * Gets all registered routes.
618
+ */
619
+ getRoutes(): RouteDefinition[]
620
+ /**
621
+ * Destroys the router.
622
+ */
623
+ destroy(): void
624
+ }
625
+ ```
626
+
627
+ #### `RouterConfig`
628
+
629
+ Configuration options for creating a router instance.
630
+
631
+ ```typescript
632
+ interface RouterConfig {
633
+ /**
634
+ * Router mode.
635
+ */
636
+ mode?: 'history' | 'hash' | 'memory'
637
+ /**
638
+ * Base path.
639
+ */
640
+ basePath?: string
641
+ /**
642
+ * Initial routes.
643
+ */
644
+ routes?: RouteDefinition[]
645
+ }
646
+ ```
647
+
648
+ #### `RouterProviderProps`
649
+
650
+ Props for router provider component.
651
+
652
+ ```typescript
653
+ interface RouterProviderProps extends ProviderProps {
654
+ router: Router
655
+ }
656
+ ```
657
+
658
+ #### `SendMessageOptions`
659
+
660
+ Options for {@link UseChatResult.sendMessage}.
661
+
662
+ ```typescript
663
+ interface SendMessageOptions {
664
+ /**
665
+ * Skip the optimistic local user-message bubble. The text is still sent to
666
+ * the server. Used for ask_user responses: the answer is folded into the
667
+ * ask_user tool card (a checkmark on the chosen option, or the custom text
668
+ * shown in-card) rather than echoed as a separate message below it.
669
+ */
670
+ suppressUserMessage?: boolean
671
+ /**
672
+ * Mark this send as issued automatically on the user's behalf (e.g. an
673
+ * auto-fix prompt). The optimistic local bubble and the persisted message are
674
+ * flagged `automatic` so the chat renders it in the distinct auto-sent style
675
+ * (agent avatar + accent border) instead of looking like the user typed it.
676
+ */
677
+ automatic?: boolean
678
+ /**
679
+ * Mark this send as the answer to the pending `ask_user` question. The most
680
+ * recent unanswered `ask_user` tool call in the store is resolved in place —
681
+ * its `output` is set to this answer — so the chosen option stays checked
682
+ * across remounts (e.g. the discovery→IDE transition) instead of relying on
683
+ * ephemeral component state that the answer's selection would otherwise lose.
684
+ * Distinct from {@link suppressUserMessage} (which the post-boot kickoff also
685
+ * sets) so resolving never misfires on a non-ask_user suppressed send.
686
+ */
687
+ askUserAnswer?: boolean
688
+ /**
689
+ * Mark an {@link automatic} send as directly requested by the user (e.g. the
690
+ * editor's "Fix with AI" action, the broken-preview overlay's "Fix with AI"
691
+ * button) rather than dispatched autonomously by the platform. A user Stop
692
+ * suppresses autonomous automatic sends until the user re-engages; a
693
+ * user-initiated one IS that re-engagement — it clears the stop and sends.
694
+ */
695
+ userInitiated?: boolean
696
+ }
697
+ ```
698
+
699
+ #### `StateProviderProps`
700
+
701
+ Props for state provider component.
702
+
703
+ ```typescript
704
+ interface StateProviderProps extends ProviderProps {
705
+ provider: StateProvider
706
+ }
707
+ ```
708
+
709
+ #### `StorageProviderProps`
710
+
711
+ Props for storage provider component.
712
+
713
+ ```typescript
714
+ interface StorageProviderProps extends ProviderProps {
715
+ provider: StorageProvider
716
+ }
717
+ ```
718
+
719
+ #### `Store`
720
+
721
+ Reactive state container with getState, setState, subscribe, and destroy.
722
+
723
+ All state management providers must implement this interface.
724
+
725
+ ```typescript
726
+ interface Store<T> {
727
+ /**
728
+ * Gets the current state.
729
+ */
730
+ getState(): T
731
+ /**
732
+ * Sets the state (partial or via updater function).
733
+ */
734
+ setState(partial: Partial<T> | ((state: T) => Partial<T>)): void
735
+ /**
736
+ * Subscribes to state changes.
737
+ * Returns an unsubscribe function.
738
+ */
739
+ subscribe(listener: StateListener<T>): () => void
740
+ /**
741
+ * Destroys the store and cleans up subscriptions.
742
+ */
743
+ destroy(): void
744
+ }
745
+ ```
746
+
747
+ #### `StoreConfig`
748
+
749
+ Configuration for creating a store (initial state, optional name, and middleware chain).
750
+
751
+ ```typescript
752
+ interface StoreConfig<T> {
753
+ /**
754
+ * Initial state value.
755
+ */
756
+ initialState: T
757
+ /**
758
+ * Optional name for debugging.
759
+ */
760
+ name?: string
761
+ /**
762
+ * Optional middleware functions.
763
+ */
764
+ middleware?: StoreMiddleware<T>[]
765
+ }
766
+ ```
767
+
768
+ #### `Theme`
769
+
770
+ Complete theme definition.
771
+
772
+ ```typescript
773
+ interface Theme {
774
+ name: string
775
+ mode: 'light' | 'dark'
776
+ colors: ThemeColors
777
+ breakpoints: ThemeBreakpoints
778
+ spacing: ThemeSpacing
779
+ typography: ThemeTypography
780
+ borderRadius: ThemeBorderRadius
781
+ shadows: ThemeShadows
782
+ transitions: ThemeTransitions
783
+ zIndex: ThemeZIndex
784
+ }
785
+ ```
786
+
787
+ #### `ThemeProviderProps`
788
+
789
+ Props for theme provider component.
790
+
791
+ ```typescript
792
+ interface ThemeProviderProps extends ProviderProps {
793
+ provider: ThemeProvider
794
+ initialTheme?: string
795
+ }
796
+ ```
797
+
798
+ #### `UseAIModelsResult`
799
+
800
+ Result returned by `useAIModels`.
801
+
802
+ ```typescript
803
+ interface UseAIModelsResult {
804
+ /** Available models, or an empty array while loading. */
805
+ models: AppModelDefinition[]
806
+ /**
807
+ * Per-mode server default model ids for the requester's tier, or `undefined`
808
+ * while loading or on servers that don't provide them.
809
+ */
810
+ defaults: AppModeModelDefaults | undefined
811
+ /** The single model marked `freeTier: true`, or `undefined`. */
812
+ freeTierModel: AppModelDefinition | undefined
813
+ /** `true` while the initial fetch is in flight. */
814
+ loading: boolean
815
+ /** Error from the initial fetch, or `null`. */
816
+ error: Error | null
817
+ }
818
+ ```
819
+
820
+ #### `UseAppStateResult`
821
+
822
+ Result from the useAppState hook.
823
+
824
+ ```typescript
825
+ interface UseAppStateResult {
826
+ /** Current app state: 'active' | 'background' | 'inactive' */
827
+ appState: string
828
+ /** Whether the app is in the foreground */
829
+ isActive: boolean
830
+ }
831
+ ```
832
+
833
+ #### `UseAuthOptions`
834
+
835
+ Hook options for useAuth.
836
+
837
+ ```typescript
838
+ interface UseAuthOptions {
839
+ /**
840
+ * Whether to automatically refresh the token on mount.
841
+ */
842
+ autoRefresh?: boolean
843
+ }
844
+ ```
845
+
846
+ #### `UseAuthResult`
847
+
848
+ Hook result for useAuth.
849
+
850
+ ```typescript
851
+ interface UseAuthResult<T = unknown> {
852
+ state: AuthState<T>
853
+ login: AuthClient<T>['login']
854
+ logout: AuthClient<T>['logout']
855
+ register: AuthClient<T>['register']
856
+ refresh: AuthClient<T>['refresh']
857
+ setUser: AuthClient<T>['setUser']
858
+ isAuthenticated: boolean
859
+ isLoading: boolean
860
+ user: T | null
861
+ }
862
+ ```
863
+
864
+ #### `UseBackHandlerOptions`
865
+
866
+ Options for the useBackHandler hook.
867
+
868
+ ```typescript
869
+ interface UseBackHandlerOptions {
870
+ /** Whether the handler is enabled. Defaults to true. */
871
+ enabled?: boolean
872
+ }
873
+ ```
874
+
875
+ #### `UseChangePasswordReturn`
876
+
877
+ Return type for useChangePassword hook.
878
+
879
+ ```typescript
880
+ interface UseChangePasswordReturn {
881
+ status: UsePromiseState<void>['status']
882
+ error: UsePromiseState<void>['error']
883
+ changePassword: (oldPassword: string, newPassword: string) => Promise<void>
884
+ reset: () => void
885
+ }
886
+ ```
887
+
888
+ #### `UseChatOptions`
889
+
890
+ Hook options for useChat.
891
+
892
+ ```typescript
893
+ interface UseChatOptions {
894
+ /** Chat endpoint (e.g., '/projects/123/chat'). */
895
+ endpoint: string
896
+ /** Project ID for context. */
897
+ projectId?: string
898
+ /**
899
+ * Display name of the AI coding agent, interpolated into user-facing chat
900
+ * copy (e.g. the stalled-stream notice). The host passes its own agent brand
901
+ * name; defaults to the neutral `DEFAULT_AGENT_NAME` so the shared hook never
902
+ * names a specific product.
903
+ */
904
+ agentName?: string
905
+ /** Load history on mount. */
906
+ loadOnMount?: boolean
907
+ /** Called when a file is created or modified by a tool call (path + new content). */
908
+ onFileChange?: (path: string, content: string) => void
909
+ /** Called when the AI switches between plan and execute modes. */
910
+ onModeChange?: (mode: 'plan' | 'execute') => void
911
+ /** Called when the backend assigns or confirms a conversation ID. */
912
+ onConversationId?: (id: string) => void
913
+ /** Called for every streaming event — useful for notifications, sounds, etc. */
914
+ onStreamEvent?: (event: ChatStreamEvent) => void
915
+ }
916
+ ```
917
+
918
+ #### `UseChatResult`
919
+
920
+ Hook result for useChat.
921
+
922
+ ```typescript
923
+ interface UseChatResult {
924
+ messages: ChatMessage[]
925
+ isLoading: boolean
926
+ /**
927
+ * True while a backend turn for this conversation streams WITHOUT this client
928
+ * owning the request — a turn started in another tab, by a teammate, or any
929
+ * server-side continuation. Detected from pushed (broadcast) chat events and
930
+ * confirmed/cleared against the server's `streaming` history flag, so the Stop
931
+ * control can stay visible and functional whenever ANY backend turn is live —
932
+ * not only for sends this hook instance made.
933
+ */
934
+ isRemoteStreaming: boolean
935
+ /**
936
+ * Tell the hook a pushed (broadcast) chat event arrived for this conversation.
937
+ * The host (ChatPanel) calls this from its push-channel handler; the hook then
938
+ * confirms against the server's `streaming` flag and, while a remote turn is
939
+ * live, keeps `isRemoteStreaming` true until the server reports it finished.
940
+ */
941
+ noteRemoteStreamEvent: () => void
942
+ error: string | null
943
+ /** Metadata about a limit-related error (for contextual upgrade CTAs). */
944
+ errorMeta: {
945
+ limitType?: string
946
+ requiresSignup?: boolean
947
+ } | null
948
+ /** Current agent mode — plan (read-only research) or execute (full access). */
949
+ mode: 'plan' | 'execute'
950
+ /**
951
+ * Whether the conversation runs at the provider's fast/priority speed tier
952
+ * (server-persisted per conversation; hydrated from the history load's
953
+ * `fastMode` meta field, when the server provides one). Only meaningful for
954
+ * models that support a fast tier — the server ignores it otherwise.
955
+ */
956
+ fastMode: boolean
957
+ /**
958
+ * Transient label for a background phase (e.g. the post-response verification
959
+ * pass — "Type-checking the API", "Linting"), set by `status` stream events.
960
+ * The UI shows it in place of the spinner's generic rotating messages; `null`
961
+ * when no such phase is active.
962
+ */
963
+ streamingStatus: string | null
964
+ /**
965
+ * Active 5XX backoff-retry countdown, or `null` when none is pending. After a
966
+ * backend server error (HTTP 5XX) the hook does NOT surface a terminal error —
967
+ * it shows this cancelable countdown and, when it elapses, auto-resumes the
968
+ * turn where the user left off (`resume:true`). `secondsRemaining` ticks down
969
+ * once per second; `attempt` is the 1-based retry number (capped at 3). 4XX,
970
+ * limit/quota, and signup-required errors never auto-retry.
971
+ */
972
+ retryCountdown: {
973
+ secondsRemaining: number
974
+ attempt: number
975
+ } | null
976
+ /** Update the local mode state (for instant mode toggle without an AI turn). */
977
+ setMode: (mode: 'plan' | 'execute') => void
978
+ /** Update the local fast-mode state (for instant toggle without an AI turn). */
979
+ setFastMode: (fastMode: boolean) => void
980
+ sendMessage: (
981
+ message: string,
982
+ attachments?: ChatAttachment[],
983
+ options?: SendMessageOptions,
984
+ ) => Promise<void>
985
+ abort: () => void
986
+ /**
987
+ * Cancel a pending 5XX auto-retry. Clears the countdown and surfaces the
988
+ * original error (via `error`) so the user sees why the turn failed.
989
+ */
990
+ cancelRetry: () => void
991
+ clearHistory: () => Promise<void>
992
+ /** Edit the content of a queued (not yet sent) message. */
993
+ editQueuedMessage: (msgId: string, newContent: string) => void
994
+ /** Remove a queued (not yet sent) message from the queue. */
995
+ deleteQueuedMessage: (msgId: string) => void
996
+ /** Remove queued auto-fix messages whose content references the given file path. */
997
+ clearQueuedForFile: (filePath: string) => void
998
+ /**
999
+ * Append an inline transcript card (model / mode / skills / custom notice) as a
1000
+ * `role:'system'` card-message in the ONE message store. Used by the host (ChatPanel)
1001
+ * to render a TEAMMATE's broadcast `card` event live — this client's OWN cards arrive
1002
+ * through the stream and are appended internally. De-duped by the server-assigned id.
1003
+ */
1004
+ appendCardMessage: (
1005
+ id: string,
1006
+ timestamp: number,
1007
+ card: NonNullable<ChatMessage['cardEvent']>,
1008
+ ) => void
1009
+ }
1010
+ ```
1011
+
1012
+ #### `UseDeviceResult`
1013
+
1014
+ Hook return type.
1015
+
1016
+ ```typescript
1017
+ interface UseDeviceResult {
1018
+ deviceInfo: DeviceInfo
1019
+ screenInfo: ScreenInfo
1020
+ hardwareInfo: HardwareInfo
1021
+ featureSupport: FeatureSupport
1022
+ supports: (feature: keyof FeatureSupport) => boolean
1023
+ isOnline: () => boolean
1024
+ isStandalone: () => boolean
1025
+ language: string
1026
+ languages: string[]
1027
+ }
1028
+ ```
1029
+
1030
+ #### `UseEditorResult`
1031
+
1032
+ Hook result for useEditor.
1033
+
1034
+ ```typescript
1035
+ interface UseEditorResult {
1036
+ tabs: EditorTab[]
1037
+ activeFile: string | null
1038
+ openFile: (file: EditorFile) => void
1039
+ closeFile: (path: string) => void
1040
+ getContent: () => string | null
1041
+ setContent: (path: string, content: string) => void
1042
+ setActiveTab: (path: string) => void
1043
+ mount: EditorProvider['mount']
1044
+ dispose: () => void
1045
+ focus: () => void
1046
+ openDiff: (file: DiffFile) => void
1047
+ closeDiff: () => void
1048
+ pinTab: (path: string) => void
1049
+ addExtraLib: (content: string, filePath: string) => void
1050
+ onFixWithAI: (callback: (request: FixWithAIRequest) => void) => () => void
1051
+ }
1052
+ ```
1053
+
1054
+ #### `UseFormOptions`
1055
+
1056
+ Options for useForm hook.
1057
+
1058
+ ```typescript
1059
+ interface UseFormOptions<T extends Record<string, unknown>> extends FormOptions<T> {
1060
+ /**
1061
+ * Form provider's createForm function.
1062
+ */
1063
+ createForm: (options: FormOptions<T>) => FormController<T>
1064
+ }
1065
+ ```
1066
+
1067
+ #### `UseFormResult`
1068
+
1069
+ Result of useForm hook.
1070
+
1071
+ ```typescript
1072
+ interface UseFormResult<T extends Record<string, unknown>> {
1073
+ formState: FormState<T>
1074
+ isValid: boolean
1075
+ isDirty: boolean
1076
+ isSubmitting: boolean
1077
+ register: (name: keyof T, options?: RegisterOptions) => FieldRegistration
1078
+ getValue: <K extends keyof T>(name: K) => T[K]
1079
+ setValue: <K extends keyof T>(name: K, value: T[K]) => void
1080
+ getError: (name: keyof T) => string | undefined
1081
+ setError: (name: keyof T, error: string | undefined) => void
1082
+ clearErrors: () => void
1083
+ handleSubmit: (onSubmit: (values: T) => void | Promise<void>) => (event?: React.FormEvent) => void
1084
+ reset: (values?: Partial<T>) => void
1085
+ validate: () => Promise<boolean>
1086
+ }
1087
+ ```
1088
+
1089
+ #### `UseHttpOptions`
1090
+
1091
+ Options for useHttp hook.
1092
+
1093
+ ```typescript
1094
+ interface UseHttpOptions<T> extends RequestConfig {
1095
+ /**
1096
+ * Whether to execute the request immediately on mount.
1097
+ */
1098
+ immediate?: boolean
1099
+ /**
1100
+ * Callback when request succeeds.
1101
+ */
1102
+ onSuccess?: (data: T) => void
1103
+ /**
1104
+ * Callback when request fails.
1105
+ */
1106
+ onError?: (error: Error) => void
1107
+ }
1108
+ ```
1109
+
1110
+ #### `UseHttpResult`
1111
+
1112
+ Result of useHttp hook.
1113
+
1114
+ ```typescript
1115
+ interface UseHttpResult<T> extends UseHttpState<T> {
1116
+ execute: () => Promise<T | null>
1117
+ reset: () => void
1118
+ }
1119
+ ```
1120
+
1121
+ #### `UseHttpState`
1122
+
1123
+ State for async HTTP operations.
1124
+
1125
+ ```typescript
1126
+ interface UseHttpState<T> {
1127
+ data: T | null
1128
+ loading: boolean
1129
+ error: Error | null
1130
+ }
1131
+ ```
1132
+
1133
+ #### `UseKeyboardHeightResult`
1134
+
1135
+ Result from the useKeyboardHeight hook.
1136
+
1137
+ ```typescript
1138
+ interface UseKeyboardHeightResult {
1139
+ /** Current keyboard height in points (0 when hidden) */
1140
+ keyboardHeight: number
1141
+ /** Whether the keyboard is currently visible */
1142
+ isKeyboardVisible: boolean
1143
+ }
1144
+ ```
1145
+
1146
+ #### `UseLoginReturn`
1147
+
1148
+ Return type for useLogin hook.
1149
+
1150
+ ```typescript
1151
+ interface UseLoginReturn<T = unknown> {
1152
+ status: UsePromiseState<AuthResult<T>>['status']
1153
+ value: UsePromiseState<AuthResult<T>>['value']
1154
+ error: UsePromiseState<AuthResult<T>>['error']
1155
+ login: (credentials: LoginCredentials) => Promise<AuthResult<T>>
1156
+ reset: () => void
1157
+ }
1158
+ ```
1159
+
1160
+ #### `UseOAuthReturn`
1161
+
1162
+ Return type for useOAuth hook.
1163
+
1164
+ ```typescript
1165
+ interface UseOAuthReturn {
1166
+ providers: string[]
1167
+ getOAuthUrl: (provider: string) => string
1168
+ /** Full-page redirect to the provider (default). The opener page navigates away. */
1169
+ redirect: (provider: string) => void
1170
+ /**
1171
+ * Open the provider in a popup so the opener page does NOT navigate. On success
1172
+ * the session is established in the opener in place and `config.onSuccess` fires;
1173
+ * on failure `config.onError` fires. Falls back to a full-page {@link redirect}
1174
+ * when the popup is blocked.
1175
+ */
1176
+ loginViaPopup: (provider: string) => void
1177
+ }
1178
+ ```
1179
+
1180
+ #### `UsePasswordResetReturn`
1181
+
1182
+ Return type for usePasswordReset hook.
1183
+
1184
+ ```typescript
1185
+ interface UsePasswordResetReturn {
1186
+ requestStatus: UsePromiseState<void>['status']
1187
+ requestError: UsePromiseState<void>['error']
1188
+ confirmStatus: UsePromiseState<void>['status']
1189
+ confirmError: UsePromiseState<void>['error']
1190
+ requestReset: (data: PasswordResetRequest) => Promise<void>
1191
+ confirmReset: (data: PasswordResetConfirm) => Promise<void>
1192
+ reset: () => void
1193
+ }
1194
+ ```
1195
+
1196
+ #### `UsePlatformResult`
1197
+
1198
+ Hook return type.
1199
+
1200
+ ```typescript
1201
+ interface UsePlatformResult {
1202
+ platform: Platform
1203
+ isNative: boolean
1204
+ isMobile: boolean
1205
+ isDesktop: boolean
1206
+ isWeb: boolean
1207
+ isDevelopment: boolean
1208
+ isProduction: boolean
1209
+ isPlatform: (...platforms: Platform[]) => boolean
1210
+ }
1211
+ ```
1212
+
1213
+ #### `UsePreviewResult`
1214
+
1215
+ Hook result for usePreview.
1216
+
1217
+ ```typescript
1218
+ interface UsePreviewResult {
1219
+ state: PreviewState
1220
+ setUrl: (url: string) => void
1221
+ refresh: () => void
1222
+ setDevice: (device: DeviceFrame) => void
1223
+ openExternal: () => void
1224
+ /**
1225
+ * Records a navigation the running preview reported via its `molecule:navigate`
1226
+ * message — updates the displayed current location without reloading the iframe.
1227
+ * Pass `isReplace` when the preview REPLACED its current history entry (a
1228
+ * `replaceState` redirect/canonicalization) so the forward stack is preserved
1229
+ * instead of truncated (a `pushState`, the default, truncates forward).
1230
+ */
1231
+ recordNavigation: (url: string, isReplace?: boolean) => void
1232
+ /** Navigates the preview to the previous navigation-history entry (Back). */
1233
+ back: () => void
1234
+ /** Navigates the preview to the next navigation-history entry (Forward). */
1235
+ forward: () => void
1236
+ }
1237
+ ```
1238
+
1239
+ #### `UsePromiseState`
1240
+
1241
+ Extended promise state with actions.
1242
+
1243
+ ```typescript
1244
+ interface UsePromiseState<T> {
1245
+ status: PromiseStatus
1246
+ value: T | null
1247
+ error: Error | null
1248
+ cancel: (message?: string) => void
1249
+ reset: () => void
1250
+ }
1251
+ ```
1252
+
1253
+ #### `UsePushOptions`
1254
+
1255
+ Options for the usePush hook (e.g. check permission on mount).
1256
+
1257
+ ```typescript
1258
+ interface UsePushOptions {
1259
+ /**
1260
+ * Whether to check permission status on mount.
1261
+ */
1262
+ checkOnMount?: boolean
1263
+ }
1264
+ ```
1265
+
1266
+ #### `UsePushResult`
1267
+
1268
+ Hook return type.
1269
+
1270
+ ```typescript
1271
+ interface UsePushResult {
1272
+ permission: PermissionStatus | null
1273
+ token: PushToken | null
1274
+ checkPermission: () => Promise<PermissionStatus>
1275
+ requestPermission: () => Promise<PermissionStatus>
1276
+ register: (options?: PushRegisterOptions) => Promise<PushToken>
1277
+ unregister: () => Promise<void>
1278
+ onNotificationReceived: (listener: NotificationReceivedListener) => () => void
1279
+ onNotificationAction: (listener: NotificationActionListener) => () => void
1280
+ onTokenChange: (listener: TokenChangeListener) => () => void
1281
+ setBadge: (count: number) => Promise<void>
1282
+ clearBadge: () => Promise<void>
1283
+ }
1284
+ ```
1285
+
1286
+ #### `UseRouterResult`
1287
+
1288
+ Hook result for useRouter.
1289
+
1290
+ ```typescript
1291
+ interface UseRouterResult {
1292
+ location: Router['getLocation'] extends () => infer R ? R : never
1293
+ params: Record<string, string>
1294
+ query: QueryParams
1295
+ navigate: Router['navigate']
1296
+ navigateTo: Router['navigateTo']
1297
+ back: Router['back']
1298
+ forward: Router['forward']
1299
+ isActive: Router['isActive']
1300
+ }
1301
+ ```
1302
+
1303
+ #### `UseSignupReturn`
1304
+
1305
+ Return type for useSignup hook.
1306
+
1307
+ ```typescript
1308
+ interface UseSignupReturn<T = unknown> {
1309
+ status: UsePromiseState<AuthResult<T>>['status']
1310
+ value: UsePromiseState<AuthResult<T>>['value']
1311
+ error: UsePromiseState<AuthResult<T>>['error']
1312
+ signup: (data: RegisterData) => Promise<AuthResult<T>>
1313
+ reset: () => void
1314
+ }
1315
+ ```
1316
+
1317
+ #### `UseStorageValueOptions`
1318
+
1319
+ Options for useStorageValue hook.
1320
+
1321
+ ```typescript
1322
+ interface UseStorageValueOptions<T> {
1323
+ /**
1324
+ * Default value if key doesn't exist.
1325
+ */
1326
+ defaultValue?: T
1327
+ /**
1328
+ * Whether to sync across tabs/windows (if supported by storage provider).
1329
+ */
1330
+ sync?: boolean
1331
+ }
1332
+ ```
1333
+
1334
+ #### `UseStorageValueResult`
1335
+
1336
+ Result of useStorageValue hook.
1337
+
1338
+ ```typescript
1339
+ interface UseStorageValueResult<T> {
1340
+ value: T | undefined
1341
+ setValue: (value: T) => Promise<void>
1342
+ removeValue: () => Promise<void>
1343
+ loading: boolean
1344
+ error: Error | null
1345
+ }
1346
+ ```
1347
+
1348
+ #### `UseStoreOptions`
1349
+
1350
+ Hook options for useStore.
1351
+
1352
+ ```typescript
1353
+ interface UseStoreOptions<T, S> {
1354
+ selector?: (state: T) => S
1355
+ equalityFn?: (a: S, b: S) => boolean
1356
+ }
1357
+ ```
1358
+
1359
+ #### `UseThemeResult`
1360
+
1361
+ Hook result for useTheme.
1362
+
1363
+ ```typescript
1364
+ interface UseThemeResult {
1365
+ theme: Theme
1366
+ themeName: string
1367
+ setTheme: (name: string) => void
1368
+ toggleTheme: () => void
1369
+ mode: 'light' | 'dark'
1370
+ }
1371
+ ```
1372
+
1373
+ #### `UseTranslationResult`
1374
+
1375
+ Hook result for useTranslation.
1376
+
1377
+ ```typescript
1378
+ interface UseTranslationResult {
1379
+ t: I18nProvider['t']
1380
+ locale: string
1381
+ setLocale: I18nProvider['setLocale']
1382
+ locales: ReturnType<I18nProvider['getLocales']>
1383
+ formatNumber: I18nProvider['formatNumber']
1384
+ formatDate: I18nProvider['formatDate']
1385
+ direction: 'ltr' | 'rtl'
1386
+ }
1387
+ ```
1388
+
1389
+ #### `UseVersionResult`
1390
+
1391
+ Hook return type.
1392
+
1393
+ ```typescript
1394
+ interface UseVersionResult {
1395
+ state: VersionState
1396
+ isUpdateAvailable: boolean
1397
+ isChecking: boolean
1398
+ isServiceWorkerWaiting: boolean
1399
+ newVersion: string | undefined
1400
+ checkForUpdates: () => Promise<boolean>
1401
+ applyUpdate: (options?: { force?: boolean }) => void
1402
+ dismissUpdate: () => void
1403
+ startPeriodicChecks: (options?: UpdateCheckOptions) => void
1404
+ stopPeriodicChecks: () => void
1405
+ }
1406
+ ```
1407
+
1408
+ #### `UseWorkspaceResult`
1409
+
1410
+ Hook result for useWorkspace.
1411
+
1412
+ ```typescript
1413
+ interface UseWorkspaceResult {
1414
+ layout: WorkspaceLayout
1415
+ activePanel: PanelId | null
1416
+ collapsedPanels: Set<PanelId>
1417
+ togglePanel: (panelId: PanelId) => void
1418
+ resizePanel: (panelId: PanelId, size: number) => void
1419
+ setActivePanel: (panelId: PanelId) => void
1420
+ resetLayout: () => void
1421
+ }
1422
+ ```
1423
+
1424
+ #### `WorkspaceProviderProps`
1425
+
1426
+ Props for workspace provider component.
1427
+
1428
+ ```typescript
1429
+ interface WorkspaceProviderProps extends ProviderProps {
1430
+ provider: WorkspaceProvider
1431
+ }
1432
+ ```
1433
+
1434
+ ### Types
1435
+
1436
+ #### `AsyncExtendState`
1437
+
1438
+ Async-capable extendState function for partial updates.
1439
+
1440
+ ```typescript
1441
+ type AsyncExtendState<T> = (
1442
+ partial: Partial<T> | ((prev: T) => Partial<T>) | Promise<Partial<T> | ((prev: T) => Partial<T>)>,
1443
+ ) => void
1444
+ ```
1445
+
1446
+ #### `AsyncSetState`
1447
+
1448
+ Async-capable setState function.
1449
+
1450
+ ```typescript
1451
+ type AsyncSetState<T> = (value: T | ((prev: T) => T) | Promise<T | ((prev: T) => T)>) => void
1452
+ ```
1453
+
1454
+ #### `UseCapacitorAppResult`
1455
+
1456
+ Hook return type.
1457
+
1458
+ ```typescript
1459
+ type UseCapacitorAppResult = CapacitorAppState & {
1460
+ initialize: () => Promise<void>
1461
+ }
1462
+ ```
1463
+
1464
+ ### Functions
1465
+
1466
+ #### `AuthProvider(props)`
1467
+
1468
+ Provider for authentication.
1469
+
1470
+ ```typescript
1471
+ function AuthProvider({
1472
+ client,
1473
+ children,
1474
+ }: AuthProviderProps<T>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>
1475
+ ```
1476
+
1477
+ - `props` — Component props (see {@link AuthProviderProps}).
1478
+
1479
+ **Returns:** The rendered auth provider element.
1480
+
1481
+ #### `ChatProvider(props)`
1482
+
1483
+ Provider for AI chat.
1484
+
1485
+ ```typescript
1486
+ function ChatProvider({
1487
+ provider,
1488
+ children,
1489
+ }: ChatProviderProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>
1490
+ ```
1491
+
1492
+ - `props` — Component props (see {@link ChatProviderProps}).
1493
+
1494
+ **Returns:** The rendered chat provider element.
1495
+
1496
+ #### `EditorProvider(props)`
1497
+
1498
+ Provider for code editor.
1499
+
1500
+ ```typescript
1501
+ function EditorProvider({
1502
+ provider,
1503
+ children,
1504
+ }: EditorProviderProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>
1505
+ ```
1506
+
1507
+ - `props` — Component props (see {@link EditorProviderProps}).
1508
+
1509
+ **Returns:** The rendered editor provider element.
1510
+
1511
+ #### `HttpProvider(props)`
1512
+
1513
+ Provider for HTTP client.
1514
+
1515
+ ```typescript
1516
+ function HttpProvider({
1517
+ client,
1518
+ children,
1519
+ }: HttpProviderProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>
1520
+ ```
1521
+
1522
+ - `props` — Component props (see {@link HttpProviderProps}).
1523
+
1524
+ **Returns:** The rendered HTTP provider element.
1525
+
1526
+ #### `I18nProvider(props)`
1527
+
1528
+ Provider for internationalization.
1529
+
1530
+ ```typescript
1531
+ function I18nProvider({
1532
+ provider,
1533
+ children,
1534
+ }: I18nProviderProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>
1535
+ ```
1536
+
1537
+ - `props` — Component props (see {@link I18nProviderProps}).
1538
+
1539
+ **Returns:** The rendered i18n provider element.
1540
+
1541
+ #### `LoggerProvider(props)`
1542
+
1543
+ Provider for logging.
1544
+
1545
+ ```typescript
1546
+ function LoggerProvider({
1547
+ provider,
1548
+ children,
1549
+ }: LoggerProviderProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>
1550
+ ```
1551
+
1552
+ - `props` — Component props (see {@link LoggerProviderProps}).
1553
+
1554
+ **Returns:** The rendered logger provider element.
1555
+
1556
+ #### `MoleculeProvider(props)`
1557
+
1558
+ Combined provider for all molecule services.
1559
+
1560
+ Provides a convenient way to wrap your app with all molecule providers at once.
1561
+ Only providers that are passed will be included.
1562
+
1563
+ ```typescript
1564
+ function MoleculeProvider({
1565
+ children,
1566
+ state,
1567
+ auth,
1568
+ theme,
1569
+ router,
1570
+ i18n,
1571
+ http,
1572
+ storage,
1573
+ logger,
1574
+ chat,
1575
+ workspace,
1576
+ editor,
1577
+ preview,
1578
+ }: MoleculeProviderProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>
1579
+ ```
1580
+
1581
+ - `props` — Component props (see {@link MoleculeProviderProps}) — each service is optional, and ONLY the services passed are provided to the tree.
1582
+
1583
+ **Returns:** The rendered combined provider element.
1584
+
1585
+ #### `PreviewProvider(props)`
1586
+
1587
+ Provider for live preview.
1588
+
1589
+ ```typescript
1590
+ function PreviewProvider({
1591
+ provider,
1592
+ children,
1593
+ }: PreviewProviderProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>
1594
+ ```
1595
+
1596
+ - `props` — Component props (see {@link PreviewProviderProps}).
1597
+
1598
+ **Returns:** The rendered preview provider element.
1599
+
1600
+ #### `resetAIModelsCache()`
1601
+
1602
+ Test-only: drops every cached model list so the next `useAIModels` call
1603
+ refetches. Exposed for unit tests; do not call from production code.
1604
+
1605
+ ```typescript
1606
+ function resetAIModelsCache(): void
1607
+ ```
1608
+
1609
+ #### `resetChatStoresForTests()`
1610
+
1611
+ Test-only: clear all conversation stores. The store is module-level (it must
1612
+ outlive component mounts), so it persists across test cases — reset it in a
1613
+ `beforeEach` the same way tests clear `sessionStorage`.
1614
+
1615
+ ```typescript
1616
+ function resetChatStoresForTests(): void
1617
+ ```
1618
+
1619
+ #### `RouterProvider(props)`
1620
+
1621
+ Provider for routing.
1622
+
1623
+ ```typescript
1624
+ function RouterProvider({
1625
+ router,
1626
+ children,
1627
+ }: RouterProviderProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>
1628
+ ```
1629
+
1630
+ - `props` — Component props (see {@link RouterProviderProps}).
1631
+
1632
+ **Returns:** The rendered router provider element.
1633
+
1634
+ #### `StateProvider(props)`
1635
+
1636
+ Provider for state management.
1637
+
1638
+ ```typescript
1639
+ function StateProvider({
1640
+ provider,
1641
+ children,
1642
+ }: StateProviderProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>
1643
+ ```
1644
+
1645
+ - `props` — Component props (see {@link StateProviderProps}).
1646
+
1647
+ **Returns:** The rendered state provider element.
1648
+
1649
+ #### `StorageProvider(props)`
1650
+
1651
+ Provider for storage.
1652
+
1653
+ ```typescript
1654
+ function StorageProvider({
1655
+ provider,
1656
+ children,
1657
+ }: StorageProviderProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>
1658
+ ```
1659
+
1660
+ - `props` — Component props (see {@link StorageProviderProps}).
1661
+
1662
+ **Returns:** The rendered storage provider element.
1663
+
1664
+ #### `ThemeProvider(props)`
1665
+
1666
+ Provider for theming.
1667
+
1668
+ ```typescript
1669
+ function ThemeProvider({
1670
+ provider,
1671
+ children,
1672
+ }: ThemeProviderProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>
1673
+ ```
1674
+
1675
+ - `props` — Component props (see {@link ThemeProviderProps}).
1676
+
1677
+ **Returns:** The rendered theme provider element.
1678
+
1679
+ #### `useAIModels(projectId)`
1680
+
1681
+ Subscribes to the cached AI model catalog. The first mount of a scope
1682
+ triggers a single `GET /ai/models` fetch; subsequent mounts return the
1683
+ cached result.
1684
+
1685
+ ```typescript
1686
+ function useAIModels(projectId?: string): UseAIModelsResult
1687
+ ```
1688
+
1689
+ - `projectId` — Optional project scope: includes that project's custom ("bring your own AI") models on servers that support them.
1690
+
1691
+ **Returns:** Models, free-tier model, loading flag, and error.
1692
+
1693
+ #### `useAppState()`
1694
+
1695
+ Tracks whether the app is in the foreground, background, or inactive.
1696
+
1697
+ Uses React Native's `AppState` API under the hood. Falls back to
1698
+ 'active' on platforms where AppState is unavailable.
1699
+
1700
+ ```typescript
1701
+ function useAppState(): UseAppStateResult
1702
+ ```
1703
+
1704
+ **Returns:** Current app state and whether the app is active.
1705
+
1706
+ #### `useAuth(options)`
1707
+
1708
+ Hook for authentication state and actions.
1709
+
1710
+ ```typescript
1711
+ function useAuth(options?: UseAuthOptions): UseAuthResult<T>
1712
+ ```
1713
+
1714
+ - `options` — Hook options
1715
+
1716
+ **Returns:** Auth state and action methods
1717
+
1718
+ #### `useAuthClient()`
1719
+
1720
+ Hook to access the auth client from context.
1721
+
1722
+ ```typescript
1723
+ function useAuthClient(): AuthClient<T>
1724
+ ```
1725
+
1726
+ **Returns:** The auth client from context
1727
+
1728
+ #### `useBackHandler(handler, options)`
1729
+
1730
+ Registers a handler for the Android hardware back button.
1731
+
1732
+ Return `true` from the handler to prevent the default back behavior,
1733
+ or `false` to allow it.
1734
+
1735
+ ```typescript
1736
+ function useBackHandler(handler: () => boolean, options?: UseBackHandlerOptions): void
1737
+ ```
1738
+
1739
+ - `handler` — Callback invoked when the hardware back button is pressed.
1740
+ - `options` — Optional configuration.
1741
+
1742
+ #### `useCapacitorApp(options)`
1743
+
1744
+ Hook for Capacitor app initialization and state management.
1745
+
1746
+ Creates a `CapacitorApp` coordinator on mount, subscribes to state changes,
1747
+ and auto-initializes. Cleans up listeners on unmount via `destroy()`.
1748
+
1749
+ ```typescript
1750
+ function useCapacitorApp(options?: CapacitorAppOptions): UseCapacitorAppResult
1751
+ ```
1752
+
1753
+ - `options` — Capacitor app configuration options
1754
+
1755
+ **Returns:** Current app state and an `initialize` function for manual re-initialization
1756
+
1757
+ #### `useChangePassword()`
1758
+
1759
+ Hook for changing password with async state tracking.
1760
+
1761
+ ```typescript
1762
+ function useChangePassword(): UseChangePasswordReturn
1763
+ ```
1764
+
1765
+ **Returns:** Change password state and action
1766
+
1767
+ #### `useChat(options)`
1768
+
1769
+ Hook for AI chat with streaming support.
1770
+
1771
+ Manages message state, sends messages to the backend, and handles
1772
+ SSE streaming responses.
1773
+
1774
+ ```typescript
1775
+ function useChat(options: UseChatOptions): UseChatResult
1776
+ ```
1777
+
1778
+ - `options` — Chat configuration including endpoint URL, project ID, and whether to load history on mount.
1779
+
1780
+ **Returns:** Chat state and controls: messages, isLoading, error, sendMessage, abort, and clearHistory.
1781
+
1782
+ #### `useChatProvider()`
1783
+
1784
+ Access the chat provider from context.
1785
+
1786
+ ```typescript
1787
+ function useChatProvider(): ChatProvider
1788
+ ```
1789
+
1790
+ **Returns:** The ChatProvider instance from the nearest ChatContext.
1791
+
1792
+ #### `useChildLogger(parentName, context)`
1793
+
1794
+ Hook to create a child logger with additional context.
1795
+
1796
+ ```typescript
1797
+ function useChildLogger(parentName: string, context: Record<string, unknown>): Logger
1798
+ ```
1799
+
1800
+ - `parentName` — Parent logger name
1801
+ - `context` — Additional context to include in logs
1802
+
1803
+ **Returns:** Child logger instance
1804
+
1805
+ #### `useCurrentTheme()`
1806
+
1807
+ Hook to get just the current theme object.
1808
+
1809
+ ```typescript
1810
+ function useCurrentTheme(): Theme
1811
+ ```
1812
+
1813
+ **Returns:** The current theme
1814
+
1815
+ #### `useDelete(url, options)`
1816
+
1817
+ Hook for DELETE requests.
1818
+
1819
+ ```typescript
1820
+ function useDelete(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
1821
+ ```
1822
+
1823
+ - `url` — Request URL of the resource to delete.
1824
+ - `options` — HTTP request options including callbacks.
1825
+
1826
+ **Returns:** Request state (data, loading, error) and controls (execute, reset).
1827
+
1828
+ #### `useDevice()`
1829
+
1830
+ Hook for device information.
1831
+
1832
+ Uses module-level `getProvider()` — device info is a singleton, not context-provided.
1833
+ Device info is static and doesn't change at runtime, so this uses `useMemo`.
1834
+
1835
+ ```typescript
1836
+ function useDevice(): UseDeviceResult
1837
+ ```
1838
+
1839
+ **Returns:** Device information and utility methods
1840
+
1841
+ #### `useDirection()`
1842
+
1843
+ Hook to get the text direction.
1844
+
1845
+ ```typescript
1846
+ function useDirection(): 'ltr' | 'rtl'
1847
+ ```
1848
+
1849
+ **Returns:** The text direction ('ltr' or 'rtl')
1850
+
1851
+ #### `useEditor()`
1852
+
1853
+ Hook for code editor management.
1854
+
1855
+ ```typescript
1856
+ function useEditor(): UseEditorResult
1857
+ ```
1858
+
1859
+ **Returns:** Editor state and controls: tabs, activeFile, openFile, closeFile, getContent, setContent, setActiveTab, mount, dispose, and focus.
1860
+
1861
+ #### `useEditorProvider()`
1862
+
1863
+ Access the editor provider from context.
1864
+
1865
+ ```typescript
1866
+ function useEditorProvider(): EditorProvider
1867
+ ```
1868
+
1869
+ **Returns:** The EditorProvider instance from the nearest EditorContext.
1870
+
1871
+ #### `useFieldState(form, name)`
1872
+
1873
+ Hook to get field-level state.
1874
+
1875
+ ```typescript
1876
+ function useFieldState(form: FormController<T>, name: keyof T): FieldState<T[keyof T]>
1877
+ ```
1878
+
1879
+ - `form` — Form controller
1880
+ - `name` — Field name
1881
+
1882
+ **Returns:** Field state (value, error, touched, dirty, valid)
1883
+
1884
+ #### `useForm(options)`
1885
+
1886
+ Hook for form state management.
1887
+
1888
+ ```typescript
1889
+ function useForm(options: UseFormOptions<T>): UseFormResult<T>
1890
+ ```
1891
+
1892
+ - `options` — Form options including createForm from a forms provider
1893
+
1894
+ **Returns:** Form state and methods
1895
+
1896
+ #### `useGet(url, options)`
1897
+
1898
+ Hook for GET requests.
1899
+
1900
+ ```typescript
1901
+ function useGet(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
1902
+ ```
1903
+
1904
+ - `url` — Request URL to fetch from.
1905
+ - `options` — HTTP request options including callbacks and request config.
1906
+
1907
+ **Returns:** Request state (data, loading, error) and controls (execute, reset).
1908
+
1909
+ #### `useHttp(method, url, options)`
1910
+
1911
+ Hook for making HTTP requests with state management.
1912
+
1913
+ ```typescript
1914
+ function useHttp(
1915
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
1916
+ url: string,
1917
+ options?: UseHttpOptions<T>,
1918
+ ): UseHttpResult<T>
1919
+ ```
1920
+
1921
+ - `method` — HTTP method
1922
+ - `url` — Request URL
1923
+ - `options` — Request options
1924
+
1925
+ **Returns:** Request state and execute function
1926
+
1927
+ #### `useHttpClient()`
1928
+
1929
+ Hook to access the HTTP client from context.
1930
+
1931
+ ```typescript
1932
+ function useHttpClient(): HttpClient
1933
+ ```
1934
+
1935
+ **Returns:** The HTTP client from context
1936
+
1937
+ #### `useI18nError(error)`
1938
+
1939
+ Translates an error at render time so the displayed message updates automatically
1940
+ when the locale changes.
1941
+
1942
+ **Always use this hook to display errors in React components** — accessing
1943
+ `error.message` directly bypasses re-translation and leaves stale text after a
1944
+ locale switch. If `error` is an `I18nError` (thrown via `throw new I18nError(key)`),
1945
+ its key is translated using the current locale. For plain `Error` instances,
1946
+ `error.message` is returned unchanged.
1947
+
1948
+ ```typescript
1949
+ function useI18nError(error: Error | null | undefined): string | null
1950
+ ```
1951
+
1952
+ - `error` — The error to translate, or `null`/`undefined`.
1953
+
1954
+ **Returns:** The translated error string, or `null` if no error.
1955
+
1956
+ #### `useI18nProvider()`
1957
+
1958
+ Hook to access the i18n provider from context.
1959
+
1960
+ ```typescript
1961
+ function useI18nProvider(): I18nProvider
1962
+ ```
1963
+
1964
+ **Returns:** The i18n provider from context
1965
+
1966
+ #### `useIsActive(path, exact)`
1967
+
1968
+ Hook to check if a path is active.
1969
+
1970
+ ```typescript
1971
+ function useIsActive(path: string, exact?: boolean): boolean
1972
+ ```
1973
+
1974
+ - `path` — The path to check
1975
+ - `exact` — Whether to match exactly (default: false)
1976
+
1977
+ **Returns:** Whether the path is active
1978
+
1979
+ #### `useIsAuthenticated()`
1980
+
1981
+ Hook to check if user is authenticated.
1982
+
1983
+ ```typescript
1984
+ function useIsAuthenticated(): boolean
1985
+ ```
1986
+
1987
+ **Returns:** Whether the user is authenticated
1988
+
1989
+ #### `useKeyboardHeight()`
1990
+
1991
+ Tracks soft keyboard visibility and height.
1992
+
1993
+ Uses React Native's `Keyboard` API. Falls back to hidden state
1994
+ on platforms where Keyboard is unavailable.
1995
+
1996
+ ```typescript
1997
+ function useKeyboardHeight(): UseKeyboardHeightResult
1998
+ ```
1999
+
2000
+ **Returns:** Current keyboard height and visibility state.
2001
+
2002
+ #### `useLocale()`
2003
+
2004
+ Hook to get the current locale.
2005
+
2006
+ ```typescript
2007
+ function useLocale(): string
2008
+ ```
2009
+
2010
+ **Returns:** The current locale code
2011
+
2012
+ #### `useLocation()`
2013
+
2014
+ Hook to get the current location.
2015
+
2016
+ ```typescript
2017
+ function useLocation(): RouteLocation
2018
+ ```
2019
+
2020
+ **Returns:** The current route location
2021
+
2022
+ #### `useLogger(name, config)`
2023
+
2024
+ Hook to get a logger instance.
2025
+
2026
+ ```typescript
2027
+ function useLogger(name: string, config?: Partial<LoggerConfig>): Logger
2028
+ ```
2029
+
2030
+ - `name` — Logger name (usually component or module name)
2031
+ - `config` — Optional logger configuration
2032
+
2033
+ **Returns:** Logger instance
2034
+
2035
+ #### `useLoggerProvider()`
2036
+
2037
+ Hook to access the logger provider from context.
2038
+
2039
+ ```typescript
2040
+ function useLoggerProvider(): LoggerProvider
2041
+ ```
2042
+
2043
+ **Returns:** The logger provider from context
2044
+
2045
+ #### `useLogin()`
2046
+
2047
+ Hook for login with async state tracking.
2048
+
2049
+ ```typescript
2050
+ function useLogin(): UseLoginReturn<T>
2051
+ ```
2052
+
2053
+ **Returns:** Login state and action
2054
+
2055
+ #### `useNavigate()`
2056
+
2057
+ Hook to get the navigate function.
2058
+
2059
+ ```typescript
2060
+ function useNavigate(): (path: string, options?: NavigateOptions) => void
2061
+ ```
2062
+
2063
+ **Returns:** The navigate function
2064
+
2065
+ #### `useOAuth(config)`
2066
+
2067
+ Hook for OAuth authentication.
2068
+
2069
+ Reads OAuth configuration from the provided config and provides
2070
+ helpers to build OAuth URLs and start a login (full-page or popup).
2071
+ Automatically handles OAuth callbacks by detecting `code` and `state`
2072
+ URL parameters and exchanging them for a session — and, when the callback is
2073
+ running inside a popup we opened, relaying the result to the opener instead.
2074
+
2075
+ ```typescript
2076
+ function useOAuth(config?: {
2077
+ baseURL?: string
2078
+ oauthProviders?: string[]
2079
+ oauthEndpoint?: string
2080
+ loginEndpoint?: string
2081
+ onSuccess?: () => void
2082
+ onError?: (error: string) => void
2083
+ }): UseOAuthReturn
2084
+ ```
2085
+
2086
+ - `config` — Optional OAuth configuration override.
2087
+ - `config.baseURL` — Base URL for the API server (e.g. "https://api.example.com").
2088
+ - `config.oauthProviders` — List of supported OAuth provider names (e.g. ["google", "github"]).
2089
+ - `config.oauthEndpoint` — Path prefix for OAuth routes (defaults to "/oauth").
2090
+ - `config.loginEndpoint` — Path for the OAuth login POST endpoint (defaults to "/users/log-in/oauth").
2091
+ - `config.onSuccess` — Callback after successful OAuth login.
2092
+ - `config.onError` — Callback on OAuth login failure.
2093
+
2094
+ **Returns:** OAuth helpers: providers, getOAuthUrl, redirect, and loginViaPopup.
2095
+
2096
+ #### `useParams()`
2097
+
2098
+ Hook to get route parameters.
2099
+
2100
+ ```typescript
2101
+ function useParams(): T
2102
+ ```
2103
+
2104
+ **Returns:** The current route parameters
2105
+
2106
+ #### `usePasswordReset()`
2107
+
2108
+ Hook for password reset flow with async state tracking.
2109
+
2110
+ Provides separate tracking for the request and confirm steps.
2111
+
2112
+ ```typescript
2113
+ function usePasswordReset(): UsePasswordResetReturn
2114
+ ```
2115
+
2116
+ **Returns:** Password reset state and actions
2117
+
2118
+ #### `usePatch(url, options)`
2119
+
2120
+ Hook for PATCH requests.
2121
+
2122
+ ```typescript
2123
+ function usePatch(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
2124
+ ```
2125
+
2126
+ - `url` — Request URL to send the PATCH request to.
2127
+ - `options` — HTTP request options including partial body data and callbacks.
2128
+
2129
+ **Returns:** Request state (data, loading, error) and controls (execute, reset).
2130
+
2131
+ #### `usePlatform()`
2132
+
2133
+ Hook for platform detection.
2134
+
2135
+ Uses module-level functions — platform is a singleton, not context-provided.
2136
+ Platform info is static and doesn't change at runtime, so this uses `useMemo`.
2137
+
2138
+ ```typescript
2139
+ function usePlatform(): UsePlatformResult
2140
+ ```
2141
+
2142
+ **Returns:** Platform information and utility methods
2143
+
2144
+ #### `usePost(url, options)`
2145
+
2146
+ Hook for POST requests.
2147
+
2148
+ ```typescript
2149
+ function usePost(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
2150
+ ```
2151
+
2152
+ - `url` — Request URL to post to.
2153
+ - `options` — HTTP request options including body data and callbacks.
2154
+
2155
+ **Returns:** Request state (data, loading, error) and controls (execute, reset).
2156
+
2157
+ #### `usePreview()`
2158
+
2159
+ Hook for live preview management.
2160
+
2161
+ ```typescript
2162
+ function usePreview(): UsePreviewResult
2163
+ ```
2164
+
2165
+ **Returns:** Preview state and controls: state (url, isLoading, device, error, isConnected), setUrl, refresh, setDevice, and openExternal.
2166
+
2167
+ #### `usePreviewProvider()`
2168
+
2169
+ Access the preview provider from context.
2170
+
2171
+ ```typescript
2172
+ function usePreviewProvider(): PreviewProvider
2173
+ ```
2174
+
2175
+ **Returns:** The PreviewProvider instance from the nearest PreviewContext.
2176
+
2177
+ #### `usePush(options)`
2178
+
2179
+ Hook for push notification state and actions.
2180
+
2181
+ Uses module-level `getProvider()` — push is a singleton, not context-provided.
2182
+
2183
+ ```typescript
2184
+ function usePush(options?: UsePushOptions): UsePushResult
2185
+ ```
2186
+
2187
+ - `options` — Hook options
2188
+
2189
+ **Returns:** Push notification state and action methods
2190
+
2191
+ #### `usePut(url, options)`
2192
+
2193
+ Hook for PUT requests.
2194
+
2195
+ ```typescript
2196
+ function usePut(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
2197
+ ```
2198
+
2199
+ - `url` — Request URL to send the PUT request to.
2200
+ - `options` — HTTP request options including body data and callbacks.
2201
+
2202
+ **Returns:** Request state (data, loading, error) and controls (execute, reset).
2203
+
2204
+ #### `useQuery()`
2205
+
2206
+ Hook to get query parameters.
2207
+
2208
+ ```typescript
2209
+ function useQuery(): T
2210
+ ```
2211
+
2212
+ **Returns:** The current query parameters
2213
+
2214
+ #### `useRootLogger()`
2215
+
2216
+ Hook to get the root logger.
2217
+
2218
+ ```typescript
2219
+ function useRootLogger(): Logger
2220
+ ```
2221
+
2222
+ **Returns:** Root logger instance
2223
+
2224
+ #### `useRouter()`
2225
+
2226
+ Hook for routing state and actions.
2227
+
2228
+ ```typescript
2229
+ function useRouter(): UseRouterResult
2230
+ ```
2231
+
2232
+ **Returns:** Router state and navigation methods
2233
+
2234
+ #### `useRouterInstance()`
2235
+
2236
+ Hook to access the router from context.
2237
+
2238
+ ```typescript
2239
+ function useRouterInstance(): Router
2240
+ ```
2241
+
2242
+ **Returns:** The router from context
2243
+
2244
+ #### `useSafeArea()`
2245
+
2246
+ Returns the current safe area insets from `react-native-safe-area-context`.
2247
+
2248
+ Must be used within a `SafeAreaProvider`. Falls back to zero insets
2249
+ if the context is unavailable.
2250
+
2251
+ ```typescript
2252
+ function useSafeArea(): SafeAreaInsets
2253
+ ```
2254
+
2255
+ **Returns:** Safe area insets for the current device.
2256
+
2257
+ #### `useSetStore(store)`
2258
+
2259
+ Hook to get the store's setState function.
2260
+
2261
+ ```typescript
2262
+ function useSetStore(store: Store<T>): (partial: Partial<T> | ((state: T) => Partial<T>)) => void
2263
+ ```
2264
+
2265
+ - `store` — The store to get setState from
2266
+
2267
+ **Returns:** The setState function
2268
+
2269
+ #### `useSignup()`
2270
+
2271
+ Hook for user registration with async state tracking.
2272
+
2273
+ ```typescript
2274
+ function useSignup(): UseSignupReturn<T>
2275
+ ```
2276
+
2277
+ **Returns:** Signup state and action
2278
+
2279
+ #### `useStateProvider()`
2280
+
2281
+ Hook to access the state provider from context.
2282
+
2283
+ ```typescript
2284
+ function useStateProvider(): StateProvider
2285
+ ```
2286
+
2287
+ **Returns:** The state provider from context
2288
+
2289
+ #### `useStorage()`
2290
+
2291
+ Hook for simple storage operations without React state sync.
2292
+
2293
+ ```typescript
2294
+ function useStorage(): {
2295
+ get: <T>(key: string) => Promise<T | null>
2296
+ set: <T>(key: string, value: T) => Promise<void>
2297
+ remove: (key: string) => Promise<void>
2298
+ clear: () => Promise<void>
2299
+ keys: () => Promise<string[]>
2300
+ }
2301
+ ```
2302
+
2303
+ **Returns:** Storage operation methods
2304
+
2305
+ #### `useStorageProvider()`
2306
+
2307
+ Hook to access the storage provider from context.
2308
+
2309
+ ```typescript
2310
+ function useStorageProvider(): StorageProvider
2311
+ ```
2312
+
2313
+ **Returns:** The storage provider from context
2314
+
2315
+ #### `useStorageValue(key, options)`
2316
+
2317
+ Hook to manage a single storage value with React state sync.
2318
+
2319
+ ```typescript
2320
+ function useStorageValue(key: string, options?: UseStorageValueOptions<T>): UseStorageValueResult<T>
2321
+ ```
2322
+
2323
+ - `key` — Storage key
2324
+ - `options` — Hook options
2325
+
2326
+ **Returns:** Storage value state (value, loading, error) and mutators (setValue, removeValue).
2327
+
2328
+ #### `useStore(store, options)`
2329
+
2330
+ Hook to subscribe to a store with optional selector and equality function.
2331
+
2332
+ ```typescript
2333
+ function useStore(store: Store<T>, options?: UseStoreOptions<T, S>): S
2334
+ ```
2335
+
2336
+ - `store` — The store to subscribe to
2337
+ - `options` — Hook options (selector, equalityFn)
2338
+
2339
+ **Returns:** The selected state
2340
+
2341
+ #### `useStoreAction(store, action)`
2342
+
2343
+ Hook to create a bound action for a store.
2344
+
2345
+ ```typescript
2346
+ function useStoreAction(
2347
+ store: Store<T>,
2348
+ action: (setState: Store<T>['setState'], getState: Store<T>['getState']) => (...args: Args) => R,
2349
+ ): (...args: Args) => R
2350
+ ```
2351
+
2352
+ - `store` — The store to bind to
2353
+ - `action` — The action function that receives setState and getState
2354
+
2355
+ **Returns:** A bound action function
2356
+
2357
+ #### `useT()`
2358
+
2359
+ Hook to get just the translation function.
2360
+
2361
+ ```typescript
2362
+ function useT(): (
2363
+ key: string,
2364
+ values?: InterpolationValues,
2365
+ options?: { defaultValue?: string; count?: number },
2366
+ ) => string
2367
+ ```
2368
+
2369
+ **Returns:** The translation function
2370
+
2371
+ #### `useTheme()`
2372
+
2373
+ Hook for theme state and actions.
2374
+
2375
+ ```typescript
2376
+ function useTheme(): UseThemeResult
2377
+ ```
2378
+
2379
+ **Returns:** Theme state and actions
2380
+
2381
+ #### `useThemeColors()`
2382
+
2383
+ Hook to get theme colors.
2384
+
2385
+ ```typescript
2386
+ function useThemeColors(): ThemeColors
2387
+ ```
2388
+
2389
+ **Returns:** The current theme colors
2390
+
2391
+ #### `useThemeMode()`
2392
+
2393
+ Hook to get just the theme mode (light/dark).
2394
+
2395
+ ```typescript
2396
+ function useThemeMode(): 'light' | 'dark'
2397
+ ```
2398
+
2399
+ **Returns:** The current theme mode
2400
+
2401
+ #### `useThemeProvider()`
2402
+
2403
+ Hook to access the theme provider from context.
2404
+
2405
+ ```typescript
2406
+ function useThemeProvider(): ThemeProvider
2407
+ ```
2408
+
2409
+ **Returns:** The theme provider from context
2410
+
2411
+ #### `useTranslation()`
2412
+
2413
+ Hook for internationalization.
2414
+
2415
+ ```typescript
2416
+ function useTranslation(): UseTranslationResult
2417
+ ```
2418
+
2419
+ **Returns:** Translation function and locale management
2420
+
2421
+ #### `useUser()`
2422
+
2423
+ Hook to get just the authenticated user.
2424
+
2425
+ ```typescript
2426
+ function useUser(): T | null
2427
+ ```
2428
+
2429
+ **Returns:** The authenticated user or null
2430
+
2431
+ #### `useVersion()`
2432
+
2433
+ Hook for version state and update actions.
2434
+
2435
+ Uses module-level `getProvider()` — version is a singleton, not context-provided.
2436
+
2437
+ ```typescript
2438
+ function useVersion(): UseVersionResult
2439
+ ```
2440
+
2441
+ **Returns:** Version state and action methods
2442
+
2443
+ #### `useWatch(form, name)`
2444
+
2445
+ Hook to watch a specific field value.
2446
+
2447
+ ```typescript
2448
+ function useWatch(form: FormController<T>, name: K): T[K]
2449
+ ```
2450
+
2451
+ - `form` — Form controller
2452
+ - `name` — Field name to watch
2453
+
2454
+ **Returns:** Current field value
2455
+
2456
+ #### `useWorkspace()`
2457
+
2458
+ Hook for IDE workspace layout management.
2459
+
2460
+ ```typescript
2461
+ function useWorkspace(): UseWorkspaceResult
2462
+ ```
2463
+
2464
+ **Returns:** The workspace state and management methods.
2465
+
2466
+ #### `useWorkspaceProvider()`
2467
+
2468
+ Access the workspace provider from context.
2469
+
2470
+ ```typescript
2471
+ function useWorkspaceProvider(): WorkspaceProvider
2472
+ ```
2473
+
2474
+ **Returns:** The result.
2475
+
2476
+ #### `WorkspaceProvider(props)`
2477
+
2478
+ Provider for IDE workspace.
2479
+
2480
+ ```typescript
2481
+ function WorkspaceProvider({
2482
+ provider,
2483
+ children,
2484
+ }: WorkspaceProviderProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>
2485
+ ```
2486
+
2487
+ - `props` — Component props (see {@link WorkspaceProviderProps}).
2488
+
2489
+ **Returns:** The rendered workspace provider element.
2490
+
2491
+ ### Constants
2492
+
2493
+ #### `AuthContext`
2494
+
2495
+ Context for authentication client.
2496
+
2497
+ ```typescript
2498
+ const AuthContext: Context<AuthClient<unknown> | null>
2499
+ ```
2500
+
2501
+ #### `ChatContext`
2502
+
2503
+ Context for AI chat provider.
2504
+
2505
+ ```typescript
2506
+ const ChatContext: Context<ChatProvider | null>
2507
+ ```
2508
+
2509
+ #### `DEFAULT_AGENT_IDENTITY`
2510
+
2511
+ The neutral default identity ({@link DEFAULT_AGENT_NAME} +
2512
+ {@link DEFAULT_PRODUCT_NAME}) the shared packages use until a consuming app
2513
+ passes its own.
2514
+
2515
+ ```typescript
2516
+ const DEFAULT_AGENT_IDENTITY: AgentIdentity
2517
+ ```
2518
+
2519
+ #### `DEFAULT_AGENT_NAME`
2520
+
2521
+ Neutral, product-agnostic agent name used when the host supplies none.
2522
+
2523
+ ```typescript
2524
+ const DEFAULT_AGENT_NAME: 'the assistant'
2525
+ ```
2526
+
2527
+ #### `DEFAULT_PRODUCT_NAME`
2528
+
2529
+ Neutral, product-agnostic product/IDE name used when the host supplies none.
2530
+
2531
+ ```typescript
2532
+ const DEFAULT_PRODUCT_NAME: 'the IDE'
2533
+ ```
2534
+
2535
+ #### `EditorContext`
2536
+
2537
+ Context for code editor provider.
2538
+
2539
+ ```typescript
2540
+ const EditorContext: Context<EditorProvider | null>
2541
+ ```
2542
+
2543
+ #### `HttpContext`
2544
+
2545
+ Context for HTTP client.
2546
+
2547
+ ```typescript
2548
+ const HttpContext: Context<HttpClient | null>
2549
+ ```
2550
+
2551
+ #### `I18nContext`
2552
+
2553
+ Context for internationalization provider.
2554
+
2555
+ ```typescript
2556
+ const I18nContext: Context<I18nProvider | null>
2557
+ ```
2558
+
2559
+ #### `LoggerContext`
2560
+
2561
+ Context for logger provider.
2562
+
2563
+ ```typescript
2564
+ const LoggerContext: Context<LoggerProvider | null>
2565
+ ```
2566
+
2567
+ #### `PreviewContext`
2568
+
2569
+ Context for live preview provider.
2570
+
2571
+ ```typescript
2572
+ const PreviewContext: Context<PreviewProvider | null>
2573
+ ```
2574
+
2575
+ #### `RouterContext`
2576
+
2577
+ Context for router.
2578
+
2579
+ ```typescript
2580
+ const RouterContext: Context<Router | null>
2581
+ ```
2582
+
2583
+ #### `StateContext`
2584
+
2585
+ Context for state management provider.
2586
+
2587
+ ```typescript
2588
+ const StateContext: Context<StateProvider | null>
2589
+ ```
2590
+
2591
+ #### `StorageContext`
2592
+
2593
+ Context for storage provider.
2594
+
2595
+ ```typescript
2596
+ const StorageContext: Context<StorageProvider | null>
2597
+ ```
2598
+
2599
+ #### `ThemeContext`
2600
+
2601
+ Context for theme provider.
2602
+
2603
+ ```typescript
2604
+ const ThemeContext: Context<ThemeProvider | null>
2605
+ ```
2606
+
2607
+ #### `useAsyncState`
2608
+
2609
+ Hook like useState but accepts Promises and supports partial state extension.
2610
+
2611
+ ```typescript
2612
+ const useAsyncState: <T>(initialState: T) => [T, AsyncSetState<T>, AsyncExtendState<T>]
2613
+ ```
2614
+
2615
+ #### `usePromise`
2616
+
2617
+ Hook that wraps an async function with state tracking.
2618
+
2619
+ ```typescript
2620
+ const usePromise: <T extends (...args: any[]) => Promise<any>>(
2621
+ asyncFn: T,
2622
+ ) => [
2623
+ UsePromiseState<Awaited<ReturnType<T>>>,
2624
+ (...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>>,
2625
+ ]
2626
+ ```
2627
+
2628
+ #### `WorkspaceContext`
2629
+
2630
+ Context for IDE workspace provider.
2631
+
2632
+ ```typescript
2633
+ const WorkspaceContext: Context<WorkspaceProvider | null>
2634
+ ```
2635
+
2636
+ ## Injection Notes
2637
+
2638
+ ### Requirements
2639
+
2640
+ Peer dependencies:
2641
+
2642
+ - `@molecule/app-keyboard` ^1.0.0
2643
+ - `@molecule/app-lifecycle` ^1.0.0
2644
+ - `@molecule/app-react` ^1.0.0
2645
+ - `react` ^18.0.0 || ^19.0.0
2646
+ - `react-native` >=0.72.0
2647
+ - `react-native-safe-area-context` >=4.0.0
2648
+
2649
+ ### Runtime Dependencies
2650
+
2651
+ - `@molecule/app-keyboard`
2652
+ - `@molecule/app-lifecycle`
2653
+ - `@molecule/app-react`
2654
+ - `react`
2655
+ - `react-native`
2656
+ - `react-native-safe-area-context`
2657
+
2658
+ - **The re-exported hooks keep `@molecule/app-react`'s contract**: each one throws unless its
2659
+ provider was passed to `MoleculeProvider` (or mounted individually). See the
2660
+ `@molecule/app-react` docs for the hook→provider map.
2661
+ - **`useSafeArea` needs `SafeAreaProvider`** (from `react-native-safe-area-context`) mounted at
2662
+ the root; without it — or without the library installed — it silently returns zero insets
2663
+ rather than throwing, so a notch-overlapped header means missing provider, not a bug in the hook.
2664
+ - `useBackHandler` only fires on Android; iOS has no hardware back button.
2665
+ - For components/styling pair this with `@molecule/app-ui-react-native`, whose ClassMap
2666
+ styling requires the NativeWind setup (`@molecule/app-ui-nativewind`) — see that package's docs.