@molecule/app-svelte 1.0.2 → 1.0.3

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
@@ -3,15 +3,11 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-09-15T19:11:43.926Z
6
+ Generated: 2026-10-21T17:02:43.425Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-svelte
10
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
11
  Svelte framework bindings for molecule.dev.
16
12
 
17
13
  Provides Svelte stores and context utilities for all molecule core
@@ -19,6 +15,10 @@ interfaces: call `setMoleculeContext(config)` once in the root layout,
19
15
  then consume services anywhere below via store factories
20
16
  (`createAuthStores`, `createThemeStores`, `createI18nStores`, …).
21
17
 
18
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
19
+ > It is written to be read by coding agents as much as by people, and is generated from this
20
+ > package's source — edit `src/index.ts` JSDoc, not this file.
21
+
22
22
  ## Quick Start
23
23
 
24
24
  ```svelte
@@ -69,119 +69,38 @@ npm install @molecule/app-svelte @molecule/app-auth @molecule/app-device @molecu
69
69
 
70
70
  ### Interfaces
71
71
 
72
- #### `AsyncStateStore`
72
+ #### `Readable`
73
73
 
74
- Async state store.
74
+ Readable interface for subscribing.
75
75
 
76
76
  ```typescript
77
- interface AsyncStateStore<T> extends Writable<T> {
78
- setState: (value: T | ((prev: T) => T) | Promise<T | ((prev: T) => T)>) => void
79
- extendState: (
80
- partial:
81
- Partial<T> | ((prev: T) => Partial<T>) | Promise<Partial<T> | ((prev: T) => Partial<T>)>,
82
- ) => void
77
+ interface Readable<T> {
78
+ /**
79
+ * Subscribe on value changes.
80
+ * @param run subscription callback
81
+ * @param invalidate cleanup callback
82
+ */
83
+ subscribe(this: void, run: Subscriber<T>, invalidate?: () => void): Unsubscriber
83
84
  }
84
85
  ```
85
86
 
86
- #### `AuthClient`
87
+ #### `Writable`
87
88
 
88
- Auth client interface that all auth bond packages must implement.
89
- Provides login/logout/register flows, token management, profile
90
- updates, and auth state subscription.
89
+ Writable interface for both updating and subscribing.
91
90
 
92
91
  ```typescript
93
- interface AuthClient<T = UserProfile> {
94
- /**
95
- * Returns the current authentication state snapshot.
96
- */
97
- getState(): AuthState<T>
98
- /**
99
- * Returns whether the user is currently authenticated.
100
- */
101
- isAuthenticated(): boolean
102
- /**
103
- * Gets the current user.
104
- */
105
- getUser(): T | null
106
- /**
107
- * Updates the cached user object (state + persistent storage) without
108
- * hitting the network. Intended for local refreshes after a per-app
109
- * mutation (e.g., the user just PATCHed their own profile and the
110
- * server returned the canonical row). Does NOT change tokens.
111
- */
112
- setUser(user: T | null): void
113
- /**
114
- * Gets the current access token.
115
- */
116
- getAccessToken(): string | null
117
- /**
118
- * Stores the access token in the configured token storage adapter (in-memory
119
- * by default). Use this to seed the token after an out-of-band exchange (e.g.
120
- * the OAuth code→token redirect) instead of writing to `localStorage` directly,
121
- * which would violate the in-memory-default storage contract and make the bearer
122
- * token JS-readable (XSS-exfiltratable). Pass `null` to clear it.
123
- */
124
- setAccessToken(token: string | null): void
125
- /**
126
- * Gets the refresh token.
127
- */
128
- getRefreshToken(): string | null
129
- /**
130
- * Logs in with credentials.
131
- */
132
- login(credentials: LoginCredentials): Promise<AuthResult<T>>
133
- /**
134
- * Logs out the current user.
135
- */
136
- logout(): Promise<void>
137
- /**
138
- * Registers a new user.
139
- */
140
- register(data: RegisterData): Promise<AuthResult<T>>
141
- /**
142
- * Refreshes the access token.
143
- */
144
- refresh(): Promise<AuthResult<T>>
145
- /**
146
- * Requests a password reset.
147
- */
148
- requestPasswordReset(data: PasswordResetRequest): Promise<void>
149
- /**
150
- * Confirms a password reset.
151
- */
152
- confirmPasswordReset(data: PasswordResetConfirm): Promise<void>
153
- /**
154
- * Updates the current user's profile.
155
- */
156
- updateProfile(data: Partial<T>): Promise<T>
157
- /**
158
- * Changes the current user's password.
159
- */
160
- changePassword(oldPassword: string, newPassword: string): Promise<void>
161
- /**
162
- * Initializes auth state (e.g., from stored tokens).
163
- */
164
- initialize(): Promise<void>
165
- /**
166
- * Subscribes to auth state changes.
167
- */
168
- subscribe(callback: (state: AuthState<T>) => void): () => void
169
- /**
170
- * Subscribes to auth state changes (alias for subscribe).
171
- */
172
- onAuthChange(callback: (state: AuthState<T>) => void): () => void
173
- /**
174
- * Gets the current access token (alias for getAccessToken).
175
- */
176
- getToken?(): string | null
92
+ interface Writable<T> extends Readable<T> {
177
93
  /**
178
- * Adds an auth event listener.
94
+ * Set value and inform subscribers.
95
+ * @param value to set
179
96
  */
180
- addEventListener(listener: AuthEventListener): () => void
97
+ set(this: void, value: T): void
98
+
181
99
  /**
182
- * Destroys the auth client.
100
+ * Update value using callback and inform subscribers.
101
+ * @param updater callback
183
102
  */
184
- destroy(): void
103
+ update(this: void, updater: Updater<T>): void
185
104
  }
186
105
  ```
187
106
 
@@ -191,6 +110,11 @@ Reactive authentication state snapshot (initialized, authenticated, user, loadin
191
110
 
192
111
  ```typescript
193
112
  interface AuthState<T = UserProfile> {
113
+ /**
114
+ * The session's state as one value — render from this instead of combining
115
+ * `initialized`/`authenticated`/`loading`. See {@link AuthStatus}.
116
+ */
117
+ status: AuthStatus
194
118
  /**
195
119
  * Whether auth state has been initialized.
196
120
  */
@@ -214,6 +138,178 @@ interface AuthState<T = UserProfile> {
214
138
  }
215
139
  ```
216
140
 
141
+ #### `AuthClient`
142
+
143
+ Auth client interface that all auth bond packages must implement.
144
+ Provides login/logout/register flows, token management, profile
145
+ updates, and auth state subscription.
146
+
147
+ ```typescript
148
+ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegister> = Record<never, never>> {
149
+ /**
150
+ * Returns the current authentication state snapshot.
151
+ *
152
+ * READING the state starts the client's one session restore when nobody has called
153
+ * {@link initialize} yet — lazily and exactly once, sharing the promise an explicit
154
+ * `initialize()` returns. A hook (`useAuth()`), a subscriber, `isAuthenticated()` and
155
+ * `getUser()` are reads too, so a client whose entry file dropped the template's
156
+ * `authClient.initialize()` line still restores instead of reporting `'loading'`
157
+ * forever.
158
+ */
159
+ getState(): AuthState<T>;
160
+ /**
161
+ * Returns whether the user is currently authenticated.
162
+ */
163
+ isAuthenticated(): boolean;
164
+ /**
165
+ * Gets the current user.
166
+ */
167
+ getUser(): T | null;
168
+ /**
169
+ * Updates the cached user object (state + persistent storage) without
170
+ * hitting the network. Intended for local refreshes after a per-app
171
+ * mutation (e.g., the user just PATCHed their own profile and the
172
+ * server returned the canonical row). Does NOT change tokens.
173
+ *
174
+ * This does not sign the client in: `authenticated` and `status` are
175
+ * unchanged, so an anonymous client stays anonymous. Use
176
+ * {@link login} / {@link register} for a credential exchange, or
177
+ * {@link setSession} when the token was issued outside the client.
178
+ */
179
+ setUser(user: T | null): void;
180
+ /**
181
+ * Gets the current access token.
182
+ */
183
+ getAccessToken(): string | null;
184
+ /**
185
+ * Stores the access token in the configured token storage adapter (in a
186
+ * browser, Web Storage; `'memory'` where no browser store exists). Use this
187
+ * to seed the token after an out-of-band exchange (e.g. the OAuth
188
+ * code→token redirect) instead of writing to `localStorage` directly,
189
+ * which would violate the storage contract and make a stored bearer token
190
+ * JS-readable (XSS-exfiltratable). Pass `null` to clear it.
191
+ *
192
+ * This changes token storage only; it does not sign the client in
193
+ * (`authenticated` and `status` are unchanged). Use {@link login} /
194
+ * {@link register} for a credential exchange, or call {@link setSession}
195
+ * with the token and the user to establish an already-issued session.
196
+ */
197
+ setAccessToken(token: string | null): void;
198
+ /**
199
+ * Adopts a session an out-of-band exchange already established: stores the
200
+ * access token (and the refresh token when given), caches the user, and
201
+ * sets the COMPLETE state — `initialized`, `authenticated`, `status:
202
+ * 'authenticated'`, no error — in one update, with one subscriber
203
+ * notification. Every hook reading the shared client sees the user as
204
+ * signed in immediately.
205
+ *
206
+ * This is the way to seed an OAuth/custom sign-in. Calling
207
+ * {@link setAccessToken} and {@link setUser} instead does NOT sign the
208
+ * client in.
209
+ */
210
+ setSession(session: AuthSessionSeed<T>): void;
211
+ /**
212
+ * Gets the refresh token.
213
+ */
214
+ getRefreshToken(): string | null;
215
+ /**
216
+ * Logs in with credentials.
217
+ */
218
+ login(credentials: LoginCredentials): Promise<AuthResult<T>>;
219
+ /**
220
+ * Logs out the current user.
221
+ */
222
+ logout(): Promise<void>;
223
+ /**
224
+ * Registers a new user. Accepts the base fields plus the app's own fields
225
+ * (`TRegister`) at the top level — see {@link RegisterData}.
226
+ */
227
+ register(data: RegisterData<TRegister>): Promise<AuthResult<T>>;
228
+ /**
229
+ * Refreshes the access token.
230
+ */
231
+ refresh(): Promise<AuthResult<T>>;
232
+ /**
233
+ * Requests a password reset.
234
+ */
235
+ requestPasswordReset(data: PasswordResetRequest): Promise<void>;
236
+ /**
237
+ * Confirms a password reset.
238
+ */
239
+ confirmPasswordReset(data: PasswordResetConfirm): Promise<void>;
240
+ /**
241
+ * Updates the current user's profile.
242
+ */
243
+ updateProfile(data: Partial<T>): Promise<T>;
244
+ /**
245
+ * Changes the current user's password.
246
+ */
247
+ changePassword(oldPassword: string, newPassword: string): Promise<void>;
248
+ /**
249
+ * Initializes auth state (e.g., from stored tokens).
250
+ *
251
+ * LAZY and IDEMPOTENT: the first read of the state ({@link getState},
252
+ * {@link subscribe}, `useAuth()`) starts this same restore when nobody has called
253
+ * `initialize()`, and every later call shares the one promise instead of sending a
254
+ * second request. An app that keeps the template's explicit call behaves exactly as
255
+ * before; an app that loses that line still restores its session.
256
+ *
257
+ * With a stored token AND a stored user it marks the session `'authenticated'`
258
+ * SYNCHRONOUSLY — before its first `await` — so the first render is the
259
+ * signed-in UI and no page waits on a verification round trip. Any check
260
+ * (a refresh, the cookie-restore probe) settles behind that render, and only an
261
+ * explicit 401/403 ends the session; a network/5xx/404 failure keeps it and
262
+ * reports `'unavailable'`. With no stored user the client stays `'loading'`
263
+ * until the cookie restore decides.
264
+ *
265
+ * Do not put this call (or a `/me` request of your own) in front of the first
266
+ * render, and do not render a loading screen over a session it just restored:
267
+ * `whenRestored()` already resolves as soon as the restore has settled, and the
268
+ * HTTP gate built on it holds requests for exactly that window.
269
+ */
270
+ initialize(): Promise<void>;
271
+ /**
272
+ * Re-checks a restored session against the server, in the background — the
273
+ * boot-time validation an app with a stored token needs when a revoked or
274
+ * expired token must sign the user out. Call it AFTER the first render
275
+ * (`initialize()` restores synchronously from storage; this costs one request).
276
+ *
277
+ * - The server confirms the user: the session is refreshed and {@link AuthState.status}
278
+ * stays `'authenticated'`.
279
+ * - The server answers 401 or 403: the token is dead — the stored session is
280
+ * cleared and the status becomes `'unauthenticated'`.
281
+ * - The server cannot confirm the session — a network failure, a 5xx, or a 404
282
+ * from a misconfigured {@link AuthClientConfig.currentUserEndpoint}: the
283
+ * session (token AND user) is KEPT and the status becomes `'unavailable'`, so
284
+ * the app can retry instead of signing the user out over a bad connection or a
285
+ * route that does not exist. The 404 error names `currentUserEndpoint`.
286
+ *
287
+ * Do not hand-write this beside the client: a parallel token/user store for a
288
+ * "validating"/"unavailable" flag is the race this method removes.
289
+ *
290
+ * Optional: a provider with no restorable session has nothing to validate.
291
+ */
292
+ validateSession?(): Promise<void>;
293
+ /**
294
+ * Resolves when the session restore started by `initialize()` has settled — the point
295
+ * after which the client knows whether this visitor is signed in.
296
+ *
297
+ * Resolves IMMEDIATELY when no restore is in flight: before `initialize()` is ever
298
+ * called, and after it has finished. A restore that failed resolves too (it settled the
299
+ * question), so an HTTP client can await this before every request without risking one
300
+ * held forever. That is what makes the fetch-before-restore race impossible: a page that
301
+ * fetches viewer-dependent data on mount waits here instead of going out anonymously
302
+ * (see `setAuthGate` in `@molecule/app-http`).
303
+ *
304
+ * Optional: a provider that restores no session has nothing to wait for. Without it, an
305
+ * HTTP client bonded to that provider sends first-paint requests unauthenticated.
306
+ *
307
+ * A provider whose restore sends a request THROUGH the gated HTTP client must send that
308
+ * request with `skipAuthGate: true` (`RequestConfig` in `@molecule/app-http`): the gate
309
+ * waits on this promise, so holding the restore's own request makes the gate wait on
310
+ // … truncated — the full declaration is in node_modules/@molecule/app-svelte/dist
311
+ ```
312
+
217
313
  #### `FormController`
218
314
 
219
315
  Form controller interface.
@@ -366,7 +462,8 @@ interface HttpClient {
366
462
  */
367
463
  defaultHeaders: Record<string, string>
368
464
  /**
369
- * Makes a generic HTTP request.
465
+ * Makes a generic HTTP request. `data` is a field of THIS config object — the same body
466
+ * `post(url, data, config)` takes as its second argument.
370
467
  */
371
468
  request<T = unknown>(config: FullRequestConfig): Promise<HttpResponse<T>>
372
469
  /**
@@ -374,15 +471,19 @@ interface HttpClient {
374
471
  */
375
472
  get<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
376
473
  /**
377
- * Makes a POST request.
474
+ * Makes a POST request. `data` is the request BODY, not a config object: the wire body is
475
+ * `data` itself, so `post(url, { data: body })` sends `{"data":body}` — pass `body` directly.
476
+ * A config (headers, params) is the THIRD argument.
378
477
  */
379
478
  post<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
380
479
  /**
381
- * Makes a PUT request.
480
+ * Makes a PUT request. `data` is the request BODY (second argument) — never `{ data: body }`,
481
+ * which sends `{"data":body}`; a config is the THIRD argument.
382
482
  */
383
483
  put<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
384
484
  /**
385
- * Makes a PATCH request.
485
+ * Makes a PATCH request. `data` is the request BODY (second argument) — never `{ data: body }`,
486
+ * which sends `{"data":body}`; a config is the THIRD argument.
386
487
  */
387
488
  patch<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
388
489
  /**
@@ -421,18 +522,6 @@ interface HttpClient {
421
522
  }
422
523
  ```
423
524
 
424
- #### `HttpState`
425
-
426
- State for async HTTP operations.
427
-
428
- ```typescript
429
- interface HttpState<T> {
430
- data: T | null
431
- loading: boolean
432
- error: Error | null
433
- }
434
- ```
435
-
436
525
  #### `I18nProvider`
437
526
 
438
527
  i18n provider interface.
@@ -691,149 +780,6 @@ interface LoggerProvider {
691
780
  }
692
781
  ```
693
782
 
694
- #### `MoleculeConfig`
695
-
696
- Configuration for molecule Svelte context.
697
-
698
- ```typescript
699
- interface MoleculeConfig {
700
- state?: StateProvider
701
- auth?: AuthClient<unknown>
702
- theme?: ThemeProvider
703
- router?: Router
704
- i18n?: I18nProvider
705
- http?: HttpClient
706
- storage?: StorageProvider
707
- logger?: LoggerProvider
708
- }
709
- ```
710
-
711
- #### `MoleculeStore`
712
-
713
- Reactive state container with getState, setState, subscribe, and destroy.
714
-
715
- All state management providers must implement this interface.
716
-
717
- ```typescript
718
- interface Store<T> {
719
- /**
720
- * Gets the current state.
721
- */
722
- getState(): T
723
- /**
724
- * Sets the state (partial or via updater function).
725
- */
726
- setState(partial: Partial<T> | ((state: T) => Partial<T>)): void
727
- /**
728
- * Subscribes to state changes.
729
- * Returns an unsubscribe function.
730
- */
731
- subscribe(listener: StateListener<T>): () => void
732
- /**
733
- * Destroys the store and cleans up subscriptions.
734
- */
735
- destroy(): void
736
- }
737
- ```
738
-
739
- #### `OAuthHelpers`
740
-
741
- OAuth helpers returned by {@link createOAuthHelpers}.
742
-
743
- ```typescript
744
- interface OAuthHelpers {
745
- /** Readable store of available OAuth provider names. */
746
- providers: Readable<string[]>
747
- /** Builds the OAuth initiation URL for a provider. */
748
- getOAuthUrl: (provider: string) => string
749
- /** Full-page redirect to the provider's OAuth initiation endpoint. */
750
- redirect: (provider: string) => void
751
- /**
752
- * Handles an OAuth callback: when the current URL carries a `code` param and
753
- * a provider was stashed by {@link redirect}, exchanges the code for a
754
- * session. A guarded no-op otherwise. Runs automatically when
755
- * {@link createOAuthHelpers} is called in a browser; exposed for manual
756
- * invocation (e.g. tests or custom callback screens).
757
- */
758
- handleCallback: () => Promise<void>
759
- }
760
- ```
761
-
762
- #### `OAuthOptions`
763
-
764
- OAuth configuration options.
765
-
766
- ```typescript
767
- interface OAuthOptions {
768
- /** Base URL for the API server (e.g. `https://api.example.com`). */
769
- baseURL?: string
770
- /** List of supported OAuth provider names (e.g. `['google', 'github']`). */
771
- oauthProviders?: string[]
772
- /** Path prefix for OAuth initiation routes. Defaults to `/oauth`. */
773
- oauthEndpoint?: string
774
- /** Path for the OAuth login POST endpoint. Defaults to `/users/log-in/oauth`. */
775
- loginEndpoint?: string
776
- /** Callback fired after a successful OAuth login. */
777
- onSuccess?: () => void
778
- /** Callback fired with an error message when the OAuth login fails. */
779
- onError?: (error: string) => void
780
- /**
781
- * Explicit auth client used to establish the session after the callback
782
- * exchange. Defaults to the client in Svelte context (only resolvable when
783
- * called during component initialization) — pass one explicitly for
784
- * callers/tests outside a component/context.
785
- */
786
- authClient?: AuthClient<unknown>
787
- }
788
- ```
789
-
790
- #### `PasswordResetStores`
791
-
792
- Password reset stores.
793
-
794
- ```typescript
795
- interface PasswordResetStores {
796
- request: Readable<PromiseState<void>> & {
797
- call: (data: PasswordResetRequest) => Promise<void>
798
- cancel: (message?: string) => void
799
- reset: () => void
800
- }
801
- confirm: Readable<PromiseState<void>> & {
802
- call: (data: PasswordResetConfirm) => Promise<void>
803
- cancel: (message?: string) => void
804
- reset: () => void
805
- }
806
- resetAll: () => void
807
- }
808
- ```
809
-
810
- #### `PromiseStore`
811
-
812
- Promise store with action methods.
813
-
814
- ```typescript
815
- interface PromiseStore<T> extends Readable<PromiseState<T>> {
816
- call: (...args: any[]) => Promise<T>
817
- cancel: (message?: string) => void
818
- reset: () => void
819
- }
820
- ```
821
-
822
- #### `Readable`
823
-
824
- Readable interface for subscribing.
825
-
826
- ```typescript
827
- interface Readable<T> {
828
- /**
829
- * Subscribe on value changes.
830
- * @param run subscription callback
831
- * @param invalidate cleanup callback
832
- */
833
- subscribe(this: void, run: Subscriber<T>, invalidate?: () => void): Unsubscriber
834
- }
835
- ```
836
-
837
783
  #### `RouteLocation`
838
784
 
839
785
  Current URL decomposed into pathname, search string, hash, navigation state, and unique key.
@@ -968,19 +914,68 @@ interface Router {
968
914
  }
969
915
  ```
970
916
 
971
- #### `StateProvider`
917
+ #### `StoreConfig`
972
918
 
973
- State provider interface that all state management bond packages
974
- must implement. Provides the store creation factory.
919
+ Configuration for creating a store (initial state, optional name, and middleware chain).
975
920
 
976
921
  ```typescript
977
- interface StateProvider {
922
+ interface StoreConfig<T> {
978
923
  /**
979
- * Creates a new store.
924
+ * Initial state value.
980
925
  */
981
- createStore<T>(config: StoreConfig<T>): Store<T>
982
- }
983
- ```
926
+ initialState: T
927
+ /**
928
+ * Optional name for debugging.
929
+ */
930
+ name?: string
931
+ /**
932
+ * Optional middleware functions.
933
+ */
934
+ middleware?: StoreMiddleware<T>[]
935
+ }
936
+ ```
937
+
938
+ #### `MoleculeStore`
939
+
940
+ Reactive state container with getState, setState, subscribe, and destroy.
941
+
942
+ All state management providers must implement this interface.
943
+
944
+ ```typescript
945
+ interface Store<T> {
946
+ /**
947
+ * Gets the current state.
948
+ */
949
+ getState(): T
950
+ /**
951
+ * Sets the state (partial or via updater function).
952
+ */
953
+ setState(partial: Partial<T> | ((state: T) => Partial<T>)): void
954
+ /**
955
+ * Subscribes to state changes.
956
+ * Returns an unsubscribe function.
957
+ */
958
+ subscribe(listener: StateListener<T>): () => void
959
+ /**
960
+ * Destroys the store and cleans up subscriptions.
961
+ */
962
+ destroy(): void
963
+ }
964
+ ```
965
+
966
+ #### `StateProvider`
967
+
968
+ State provider interface that all state management bond packages
969
+ must implement. Provides the store creation factory.
970
+
971
+ ```typescript
972
+ interface StateProvider {
973
+ /**
974
+ * Creates a new store.
975
+ */
976
+ createStore<T>(config: StoreConfig<T>): Store<T>
977
+ }
978
+ ```
984
979
 
985
980
  #### `StorageProvider`
986
981
 
@@ -1025,58 +1020,6 @@ interface StorageProvider {
1025
1020
  }
1026
1021
  ```
1027
1022
 
1028
- #### `StorageValueState`
1029
-
1030
- State for async storage values.
1031
-
1032
- ```typescript
1033
- interface StorageValueState<T> {
1034
- value: T | undefined
1035
- loading: boolean
1036
- error: Error | null
1037
- }
1038
- ```
1039
-
1040
- #### `StoreConfig`
1041
-
1042
- Configuration for creating a store (initial state, optional name, and middleware chain).
1043
-
1044
- ```typescript
1045
- interface StoreConfig<T> {
1046
- /**
1047
- * Initial state value.
1048
- */
1049
- initialState: T
1050
- /**
1051
- * Optional name for debugging.
1052
- */
1053
- name?: string
1054
- /**
1055
- * Optional middleware functions.
1056
- */
1057
- middleware?: StoreMiddleware<T>[]
1058
- }
1059
- ```
1060
-
1061
- #### `Theme`
1062
-
1063
- Complete theme definition.
1064
-
1065
- ```typescript
1066
- interface Theme {
1067
- name: string
1068
- mode: 'light' | 'dark'
1069
- colors: ThemeColors
1070
- breakpoints: ThemeBreakpoints
1071
- spacing: ThemeSpacing
1072
- typography: ThemeTypography
1073
- borderRadius: ThemeBorderRadius
1074
- shadows: ThemeShadows
1075
- transitions: ThemeTransitions
1076
- zIndex: ThemeZIndex
1077
- }
1078
- ```
1079
-
1080
1023
  #### `ThemeProvider`
1081
1024
 
1082
1025
  Manages theme state including the active theme, mode toggling,
@@ -1123,866 +1066,1003 @@ interface ThemeProvider {
1123
1066
  }
1124
1067
  ```
1125
1068
 
1126
- #### `Writable`
1069
+ #### `Theme`
1127
1070
 
1128
- Writable interface for both updating and subscribing.
1071
+ Complete theme definition.
1129
1072
 
1130
1073
  ```typescript
1131
- interface Writable<T> extends Readable<T> {
1132
- /**
1133
- * Set value and inform subscribers.
1134
- * @param value to set
1135
- */
1136
- set(this: void, value: T): void
1137
-
1138
- /**
1139
- * Update value using callback and inform subscribers.
1140
- * @param updater callback
1141
- */
1142
- update(this: void, updater: Updater<T>): void
1074
+ interface Theme {
1075
+ name: string
1076
+ mode: 'light' | 'dark'
1077
+ colors: ThemeColors
1078
+ breakpoints: ThemeBreakpoints
1079
+ spacing: ThemeSpacing
1080
+ typography: ThemeTypography
1081
+ borderRadius: ThemeBorderRadius
1082
+ shadows: ThemeShadows
1083
+ transitions: ThemeTransitions
1084
+ zIndex: ThemeZIndex
1143
1085
  }
1144
1086
  ```
1145
1087
 
1146
- ### Types
1147
-
1148
- #### `CapacitorAppStore`
1088
+ #### `AsyncStateStore`
1149
1089
 
1150
- Return type for the Capacitor app store.
1090
+ Async state store.
1151
1091
 
1152
1092
  ```typescript
1153
- type CapacitorAppStore = Readable<CapacitorAppState> & {
1154
- initialize: () => Promise<void>
1093
+ interface AsyncStateStore<T> extends Writable<T> {
1094
+ setState: (value: T | ((prev: T) => T) | Promise<T | ((prev: T) => T)>) => void
1095
+ extendState: (
1096
+ partial:
1097
+ Partial<T> | ((prev: T) => Partial<T>) | Promise<Partial<T> | ((prev: T) => Partial<T>)>,
1098
+ ) => void
1155
1099
  }
1156
1100
  ```
1157
1101
 
1158
- #### `ChangePasswordStore`
1102
+ #### `OAuthOptions`
1159
1103
 
1160
- Change password store type.
1104
+ OAuth configuration options.
1161
1105
 
1162
1106
  ```typescript
1163
- type ChangePasswordStore = PromiseStore<void>
1107
+ interface OAuthOptions {
1108
+ /** Base URL for the API server (e.g. `https://api.example.com`). */
1109
+ baseURL?: string
1110
+ /** List of supported OAuth provider names (e.g. `['google', 'github']`). */
1111
+ oauthProviders?: string[]
1112
+ /** Path prefix for OAuth initiation routes. Defaults to `/oauth`. */
1113
+ oauthEndpoint?: string
1114
+ /** Path for the OAuth login POST endpoint. Defaults to `/users/log-in/oauth`. */
1115
+ loginEndpoint?: string
1116
+ /** Callback fired after a successful OAuth login. */
1117
+ onSuccess?: () => void
1118
+ /** Callback fired with an error message when the OAuth login fails. */
1119
+ onError?: (error: string) => void
1120
+ /**
1121
+ * Explicit auth client used to establish the session after the callback
1122
+ * exchange. Defaults to the client in Svelte context (only resolvable when
1123
+ * called during component initialization) — pass one explicitly for
1124
+ * callers/tests outside a component/context.
1125
+ */
1126
+ authClient?: AuthClient<unknown>
1127
+ }
1164
1128
  ```
1165
1129
 
1166
- #### `LoginStore`
1130
+ #### `OAuthHelpers`
1167
1131
 
1168
- Login store type.
1132
+ OAuth helpers returned by {@link createOAuthHelpers}.
1169
1133
 
1170
1134
  ```typescript
1171
- type LoginStore<T = unknown> = PromiseStore<AuthResult<T>>
1135
+ interface OAuthHelpers {
1136
+ /** Readable store of available OAuth provider names. */
1137
+ providers: Readable<string[]>
1138
+ /** Builds the OAuth initiation URL for a provider. */
1139
+ getOAuthUrl: (provider: string) => string
1140
+ /** Full-page redirect to the provider's OAuth initiation endpoint. */
1141
+ redirect: (provider: string) => void
1142
+ /**
1143
+ * Handles an OAuth callback: when the current URL carries a `code` param and
1144
+ * a provider was stashed by {@link redirect}, exchanges the code for a
1145
+ * session. A guarded no-op otherwise. Runs automatically when
1146
+ * {@link createOAuthHelpers} is called in a browser; exposed for manual
1147
+ * invocation (e.g. tests or custom callback screens).
1148
+ */
1149
+ handleCallback: () => Promise<void>
1150
+ }
1172
1151
  ```
1173
1152
 
1174
- #### `QueryParams`
1153
+ #### `PasswordResetStores`
1175
1154
 
1176
- URL query string parameter map (single values or arrays for repeated keys).
1155
+ Password reset stores.
1177
1156
 
1178
1157
  ```typescript
1179
- type QueryParams = Record<string, string | string[] | undefined>
1158
+ interface PasswordResetStores {
1159
+ request: Readable<PromiseState<void>> & {
1160
+ call: (data: PasswordResetRequest) => Promise<void>
1161
+ cancel: (message?: string) => void
1162
+ reset: () => void
1163
+ }
1164
+ confirm: Readable<PromiseState<void>> & {
1165
+ call: (data: PasswordResetConfirm) => Promise<void>
1166
+ cancel: (message?: string) => void
1167
+ reset: () => void
1168
+ }
1169
+ resetAll: () => void
1170
+ }
1180
1171
  ```
1181
1172
 
1182
- #### `RouteParams`
1173
+ #### `PromiseStore`
1183
1174
 
1184
- URL path parameter key-value map extracted from dynamic route segments (e.g. `{ id: '123' }`).
1175
+ Promise store with action methods.
1185
1176
 
1186
1177
  ```typescript
1187
- type RouteParams = Record<string, string>
1178
+ interface PromiseStore<T> extends Readable<PromiseState<T>> {
1179
+ call: (...args: any[]) => Promise<T>
1180
+ cancel: (message?: string) => void
1181
+ reset: () => void
1182
+ }
1188
1183
  ```
1189
1184
 
1190
- #### `SignupStore`
1185
+ #### `MoleculeConfig`
1191
1186
 
1192
- Signup store type.
1187
+ Configuration for molecule Svelte context.
1193
1188
 
1194
1189
  ```typescript
1195
- type SignupStore<T = unknown> = PromiseStore<AuthResult<T>>
1190
+ interface MoleculeConfig {
1191
+ state?: StateProvider
1192
+ auth?: AuthClient<unknown>
1193
+ theme?: ThemeProvider
1194
+ router?: Router
1195
+ i18n?: I18nProvider
1196
+ http?: HttpClient
1197
+ storage?: StorageProvider
1198
+ logger?: LoggerProvider
1199
+ }
1196
1200
  ```
1197
1201
 
1198
- ### Functions
1199
-
1200
- #### `createAsyncState(initialValue)`
1202
+ #### `HttpState`
1201
1203
 
1202
- Creates a writable store with async-capable setState and extendState.
1204
+ State for async HTTP operations.
1203
1205
 
1204
1206
  ```typescript
1205
- function createAsyncState(initialValue: T): AsyncStateStore<T>
1207
+ interface HttpState<T> {
1208
+ data: T | null
1209
+ loading: boolean
1210
+ error: Error | null
1211
+ }
1206
1212
  ```
1207
1213
 
1208
- - `initialValue` — The initial state value
1209
-
1210
- **Returns:** The created instance.
1211
-
1212
- #### `createAuthStores()`
1214
+ #### `StorageValueState`
1213
1215
 
1214
- Create auth stores from the auth client in context.
1216
+ State for async storage values.
1215
1217
 
1216
1218
  ```typescript
1217
- function createAuthStores(): AuthStores<T> & { error: Readable<string | null> }
1219
+ interface StorageValueState<T> {
1220
+ value: T | undefined
1221
+ loading: boolean
1222
+ error: Error | null
1223
+ }
1218
1224
  ```
1219
1225
 
1220
- **Returns:** Auth stores and actions
1221
-
1222
- #### `createAuthStoresFromClient(client)`
1226
+ ### Types
1223
1227
 
1224
- Create auth stores from a specific auth client.
1228
+ #### `RouteParams`
1225
1229
 
1226
- Use this when you don't want to use context.
1230
+ URL path parameter key-value map extracted from dynamic route segments (e.g. `{ id: '123' }`).
1227
1231
 
1228
1232
  ```typescript
1229
- function createAuthStoresFromClient(client: AuthClient<T>): AuthStores<T>
1233
+ type RouteParams = Record<string, string>
1230
1234
  ```
1231
1235
 
1232
- - `client` — Auth client
1236
+ #### `QueryParams`
1233
1237
 
1234
- **Returns:** Auth stores and actions
1238
+ URL query string parameter map (single values or arrays for repeated keys).
1235
1239
 
1236
- #### `createCapacitorAppStore(options)`
1240
+ ```typescript
1241
+ type QueryParams = Record<string, string | string[] | undefined>
1242
+ ```
1237
1243
 
1238
- Create a Svelte store wrapping the Capacitor app coordinator.
1244
+ #### `CapacitorAppStore`
1239
1245
 
1240
- Creates a CapacitorApp instance, subscribes to state changes,
1241
- and auto-initializes. The returned store is readable and also
1242
- exposes an `initialize` method for manual re-initialization.
1246
+ Return type for the Capacitor app store.
1243
1247
 
1244
1248
  ```typescript
1245
- function createCapacitorAppStore(options?: CapacitorAppOptions): CapacitorAppStore
1249
+ type CapacitorAppStore = Readable<CapacitorAppState> & {
1250
+ initialize: () => Promise<void>
1251
+ }
1246
1252
  ```
1247
1253
 
1248
- - `options` — Capacitor app options
1254
+ #### `ChangePasswordStore`
1249
1255
 
1250
- **Returns:** A readable store of CapacitorAppState with an initialize method
1256
+ Change password store type.
1251
1257
 
1252
- #### `createChangePasswordStore()`
1258
+ ```typescript
1259
+ type ChangePasswordStore = PromiseStore<void>
1260
+ ```
1253
1261
 
1254
- Creates a change password store with async state tracking.
1262
+ #### `LoginStore`
1263
+
1264
+ Login store type.
1255
1265
 
1256
1266
  ```typescript
1257
- function createChangePasswordStore(): ChangePasswordStore
1267
+ type LoginStore<T = unknown> = PromiseStore<AuthResult<T>>
1258
1268
  ```
1259
1269
 
1260
- **Returns:** Change password promise store
1261
-
1262
- #### `createDeleteStore(url, config)`
1270
+ #### `SignupStore`
1263
1271
 
1264
- Creates a DELETE request store.
1272
+ Signup store type.
1265
1273
 
1266
1274
  ```typescript
1267
- function createDeleteStore(url: string, config?: RequestConfig): HttpStore<T>
1275
+ type SignupStore<T = unknown> = PromiseStore<AuthResult<T>>
1268
1276
  ```
1269
1277
 
1270
- - `url` — The request endpoint URL.
1271
- - `config` — Optional request configuration such as headers or params.
1272
-
1273
- **Returns:** A subscribable HTTP store for the DELETE request with execute and reset methods.
1278
+ ### Functions
1274
1279
 
1275
- #### `createDeviceStores()`
1280
+ #### `setMoleculeContext(config)`
1276
1281
 
1277
- Create device stores from the module-level device provider.
1282
+ Set all molecule providers in Svelte context.
1278
1283
 
1279
- Device information is static (no reactive subscription needed),
1280
- so this returns plain values rather than Svelte stores.
1284
+ Call this in your root layout/component.
1281
1285
 
1282
1286
  ```typescript
1283
- function createDeviceStores(): {
1284
- deviceInfo: DeviceInfo
1285
- screenInfo: ScreenInfo
1286
- hardwareInfo: HardwareInfo
1287
- featureSupport: FeatureSupport
1288
- supports: (feature: keyof FeatureSupport) => boolean
1289
- isOnline: () => boolean
1290
- isStandalone: () => boolean
1291
- language: string
1292
- languages: string[]
1293
- }
1287
+ function setMoleculeContext(config: MoleculeConfig): void
1294
1288
  ```
1295
1289
 
1296
- **Returns:** Device information and utility functions
1290
+ - `config` — Provider instances to register (state, auth, theme, router, i18n, http, storage, logger).
1297
1291
 
1298
- #### `createFieldStore(controller, name)`
1292
+ #### `setStateContext(provider)`
1299
1293
 
1300
- Create a readable store that tracks a single field's state.
1294
+ Sets the state context.
1301
1295
 
1302
1296
  ```typescript
1303
- function createFieldStore(controller: FormController<T>, name: K): Readable<FieldState<T[K]>>
1297
+ function setStateContext(provider: StateProvider): void
1304
1298
  ```
1305
1299
 
1306
- - `controller` — Form controller
1307
- - `name` — Field name to track
1308
-
1309
- **Returns:** Readable store of the field state
1300
+ - `provider` — The state provider to store in Svelte context.
1310
1301
 
1311
- #### `createFormStores(provider, options)`
1302
+ #### `setAuthContext(client)`
1312
1303
 
1313
- Create form stores from a form provider and options.
1304
+ Sets the auth context.
1314
1305
 
1315
1306
  ```typescript
1316
- function createFormStores(provider: FormProvider, options: FormOptions<T>): FormStores<T>
1307
+ function setAuthContext(client: AuthClient<T, Record<never, never>>): void
1317
1308
  ```
1318
1309
 
1319
- - `provider` — Form provider instance
1320
- - `options` — Form creation options
1321
-
1322
- **Returns:** Form stores and actions
1310
+ - `client` — The auth client to store in Svelte context.
1323
1311
 
1324
- #### `createGetStore(url, config)`
1312
+ #### `setThemeContext(provider)`
1325
1313
 
1326
- Creates a GET request store.
1314
+ Sets the theme context.
1327
1315
 
1328
1316
  ```typescript
1329
- function createGetStore(url: string, config?: RequestConfig): HttpStore<T>
1317
+ function setThemeContext(provider: ThemeProvider): void
1330
1318
  ```
1331
1319
 
1332
- - `url` — The request endpoint URL.
1333
- - `config` — Optional request configuration such as headers or params.
1334
-
1335
- **Returns:** A subscribable HTTP store for the GET request with execute and reset methods.
1320
+ - `provider` — The theme provider to store in Svelte context.
1336
1321
 
1337
- #### `createHttpStore(method, url, config)`
1322
+ #### `setRouterContext(router)`
1338
1323
 
1339
- Create an HTTP request store.
1324
+ Sets the router context.
1340
1325
 
1341
1326
  ```typescript
1342
- function createHttpStore(
1343
- method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
1344
- url: string,
1345
- config?: RequestConfig,
1346
- ): HttpStore<T>
1327
+ function setRouterContext(router: Router): void
1347
1328
  ```
1348
1329
 
1349
- - `method` — HTTP method
1350
- - `url` — Request URL
1351
- - `config` — Request configuration
1352
-
1353
- **Returns:** Store with state and actions
1330
+ - `router` — The router instance to store in Svelte context.
1354
1331
 
1355
- #### `createHttpStoresFromClient(client)`
1332
+ #### `setI18nContext(provider)`
1356
1333
 
1357
- Creates HTTP store factory methods bound to a specific client instance.
1334
+ Sets the i18n context.
1358
1335
 
1359
1336
  ```typescript
1360
- function createHttpStoresFromClient(client: HttpClient): HttpStoreFactory
1337
+ function setI18nContext(provider: I18nProvider): void
1361
1338
  ```
1362
1339
 
1363
- - `client` — The HTTP client to use for all created stores.
1364
-
1365
- **Returns:** An object with get, post, put, patch, and delete factory methods.
1340
+ - `provider` — The i18n provider to store in Svelte context.
1366
1341
 
1367
- #### `createI18nStores()`
1342
+ #### `setHttpContext(client)`
1368
1343
 
1369
- Create i18n stores from the i18n provider in context.
1344
+ Sets the HTTP context.
1370
1345
 
1371
1346
  ```typescript
1372
- function createI18nStores(): I18nStores
1347
+ function setHttpContext(client: HttpClient): void
1373
1348
  ```
1374
1349
 
1375
- **Returns:** I18n stores and actions
1350
+ - `client` — The HTTP client to store in Svelte context.
1376
1351
 
1377
- #### `createI18nStoresFromProvider(provider)`
1352
+ #### `setStorageContext(provider)`
1378
1353
 
1379
- Create i18n stores from a specific provider.
1354
+ Sets the storage context.
1380
1355
 
1381
1356
  ```typescript
1382
- function createI18nStoresFromProvider(provider: I18nProvider): I18nStores
1357
+ function setStorageContext(provider: StorageProvider): void
1383
1358
  ```
1384
1359
 
1385
- - `provider` — I18n provider
1386
-
1387
- **Returns:** I18n stores and actions
1360
+ - `provider` — The storage provider to store in Svelte context.
1388
1361
 
1389
- #### `createIsActiveStore(location, router, path, exact)`
1362
+ #### `setLoggerContext(provider)`
1390
1363
 
1391
- Create a derived store that checks if a path is active.
1364
+ Sets the logger context.
1392
1365
 
1393
1366
  ```typescript
1394
- function createIsActiveStore(
1395
- location: Readable<RouteLocation>,
1396
- router: Router,
1397
- path: string,
1398
- exact?: boolean,
1399
- ): Readable<boolean>
1367
+ function setLoggerContext(provider: LoggerProvider): void
1400
1368
  ```
1401
1369
 
1402
- - `location` — A readable location store (from createRouterStores or createRouterStoresFromRouter)
1403
- - `router` — Router instance (for isActive check)
1404
- - `path` — Path to check
1405
- - `exact` — Whether to require exact match (default: false)
1406
-
1407
- **Returns:** Readable store of whether the path is active
1370
+ - `provider` — The logger provider to store in Svelte context.
1408
1371
 
1409
- #### `createLogger(config)`
1372
+ #### `getStateProvider()`
1410
1373
 
1411
- Create a logger with custom configuration.
1374
+ Gets the state provider from Svelte context.
1412
1375
 
1413
1376
  ```typescript
1414
- function createLogger(config: LoggerConfig): Logger
1377
+ function getStateProvider(): StateProvider
1415
1378
  ```
1416
1379
 
1417
- - `config` — Logger configuration
1418
-
1419
- **Returns:** Logger instance
1380
+ **Returns:** The state provider instance.
1420
1381
 
1421
- #### `createLoggerHelpers()`
1382
+ #### `getAuthClient()`
1422
1383
 
1423
- Create logger helpers from context.
1384
+ Gets the auth client from Svelte context.
1424
1385
 
1425
1386
  ```typescript
1426
- function createLoggerHelpers(): LoggerHelpers
1387
+ function getAuthClient(): AuthClient<T, TRegister>
1427
1388
  ```
1428
1389
 
1429
- **Returns:** Logger helper functions
1390
+ **Returns:** The auth client instance.
1430
1391
 
1431
- #### `createLoggerHelpersFromProvider(provider)`
1392
+ #### `getThemeProvider()`
1432
1393
 
1433
- Create logger helpers from a specific provider.
1394
+ Gets the theme provider from Svelte context.
1434
1395
 
1435
1396
  ```typescript
1436
- function createLoggerHelpersFromProvider(provider: LoggerProvider): LoggerHelpers
1397
+ function getThemeProvider(): ThemeProvider
1437
1398
  ```
1438
1399
 
1439
- - `provider` — Logger provider
1440
-
1441
- **Returns:** Logger helper functions
1400
+ **Returns:** The theme provider instance.
1442
1401
 
1443
- #### `createLoginStore()`
1402
+ #### `getRouter()`
1444
1403
 
1445
- Creates a login store with async state tracking.
1404
+ Gets the router from Svelte context.
1446
1405
 
1447
1406
  ```typescript
1448
- function createLoginStore(): LoginStore<T>
1407
+ function getRouter(): Router
1449
1408
  ```
1450
1409
 
1451
- **Returns:** Login promise store
1452
-
1453
- #### `createOAuthHelpers(options)`
1454
-
1455
- Creates OAuth helpers for provider-based authentication flows.
1410
+ **Returns:** The router instance.
1456
1411
 
1457
- When created in a browser, automatically handles OAuth callbacks by
1458
- detecting `code` and `state` URL parameters and exchanging them for a
1459
- session (a guarded no-op when there is no callback code in the URL).
1412
+ #### `getI18nProvider()`
1460
1413
 
1461
- Session establishment: the exchange result is applied to the resolved auth
1462
- client (an explicit `options.authClient`, else the Svelte-context client
1463
- when created during component initialization). When NO client is available,
1464
- the server has already established the httpOnly-cookie session via the
1465
- exchange, so a user-carrying response still counts as success —
1466
- `options.onSuccess` fires; a response with no user fires `options.onError`.
1414
+ Gets the i18n provider from Svelte context.
1467
1415
 
1468
1416
  ```typescript
1469
- function createOAuthHelpers(options?: OAuthOptions): OAuthHelpers
1417
+ function getI18nProvider(): I18nProvider
1470
1418
  ```
1471
1419
 
1472
- - `options` — OAuth configuration (base URL, providers, endpoint paths, callbacks, auth client).
1473
-
1474
- **Returns:** An object containing a readable providers store, URL builder, redirect function, and callback handler.
1420
+ **Returns:** The i18n provider instance.
1475
1421
 
1476
- #### `createPasswordResetStores()`
1422
+ #### `getHttpClient()`
1477
1423
 
1478
- Creates password reset stores with async state tracking.
1424
+ Gets the HTTP client from Svelte context.
1479
1425
 
1480
1426
  ```typescript
1481
- function createPasswordResetStores(): PasswordResetStores
1427
+ function getHttpClient(): HttpClient
1482
1428
  ```
1483
1429
 
1484
- **Returns:** Password reset stores for request and confirm steps
1430
+ **Returns:** The HTTP client instance.
1485
1431
 
1486
- #### `createPatchStore(url, config)`
1432
+ #### `getStorageProvider()`
1487
1433
 
1488
- Creates a PATCH request store.
1434
+ Gets the storage provider from Svelte context.
1489
1435
 
1490
1436
  ```typescript
1491
- function createPatchStore(url: string, config?: RequestConfig): HttpStore<T>
1437
+ function getStorageProvider(): StorageProvider
1492
1438
  ```
1493
1439
 
1494
- - `url` — The request endpoint URL.
1495
- - `config` — Optional request configuration such as headers or body data.
1496
-
1497
- **Returns:** A subscribable HTTP store for the PATCH request with execute and reset methods.
1498
-
1499
- #### `createPlatformStores()`
1440
+ **Returns:** The storage provider instance.
1500
1441
 
1501
- Create platform stores from the module-level platform info.
1442
+ #### `getLoggerProvider()`
1502
1443
 
1503
- Platform information is static (no reactive subscription needed),
1504
- so this returns plain values rather than Svelte stores.
1444
+ Gets the logger provider from Svelte context.
1505
1445
 
1506
1446
  ```typescript
1507
- function createPlatformStores(): {
1508
- platform: Platform
1509
- isNative: boolean
1510
- isMobile: boolean
1511
- isDesktop: boolean
1512
- isWeb: boolean
1513
- isDevelopment: boolean
1514
- isProduction: boolean
1515
- isPlatform: (...platforms: Platform[]) => boolean
1516
- }
1447
+ function getLoggerProvider(): LoggerProvider
1517
1448
  ```
1518
1449
 
1519
- **Returns:** Platform information and utility functions
1450
+ **Returns:** The logger provider instance.
1520
1451
 
1521
- #### `createPostStore(url, config)`
1452
+ #### `createAsyncState(initialValue)`
1522
1453
 
1523
- Creates a POST request store.
1454
+ Creates a writable store with async-capable setState and extendState.
1524
1455
 
1525
1456
  ```typescript
1526
- function createPostStore(url: string, config?: RequestConfig): HttpStore<T>
1457
+ function createAsyncState(initialValue: T): AsyncStateStore<T>
1527
1458
  ```
1528
1459
 
1529
- - `url` — The request endpoint URL.
1530
- - `config` — Optional request configuration such as headers or body data.
1460
+ - `initialValue` — The initial state value
1531
1461
 
1532
- **Returns:** A subscribable HTTP store for the POST request with execute and reset methods.
1462
+ **Returns:** The created instance.
1533
1463
 
1534
- #### `createPromiseStore(asyncFn)`
1464
+ #### `createAuthStores()`
1535
1465
 
1536
- Creates a store that tracks async function state.
1466
+ Create auth stores from the auth client in context.
1537
1467
 
1538
1468
  ```typescript
1539
- function createPromiseStore(asyncFn: T): PromiseStore<Awaited<ReturnType<T>>>
1469
+ function createAuthStores(): AuthStores<T, TRegister> & { error: Readable<string | null> }
1540
1470
  ```
1541
1471
 
1542
- - `asyncFn` — The async function to track
1472
+ **Returns:** Auth stores and actions
1543
1473
 
1544
- **Returns:** Promise store with subscribe, call, cancel, and reset
1474
+ #### `createAuthStoresFromClient(client)`
1545
1475
 
1546
- #### `createPushStores()`
1476
+ Create auth stores from a specific auth client.
1547
1477
 
1548
- Create push notification stores from the module-level push provider.
1478
+ Use this when you don't want to use context.
1549
1479
 
1550
1480
  ```typescript
1551
- function createPushStores(): {
1552
- permission: Readable<PermissionStatus | null>
1553
- token: Readable<PushToken | null>
1554
- checkPermission: () => Promise<PermissionStatus>
1555
- requestPermission: () => Promise<PermissionStatus>
1556
- register: (options?: PushRegisterOptions) => Promise<PushToken>
1557
- unregister: () => Promise<void>
1558
- onNotificationReceived: (listener: NotificationReceivedListener) => () => void
1559
- onNotificationAction: (listener: NotificationActionListener) => () => void
1560
- onTokenChange: (listener: TokenChangeListener) => () => void
1561
- setBadge: (count: number) => Promise<void>
1562
- clearBadge: () => Promise<void>
1481
+ function createAuthStoresFromClient(client: AuthClient<T, TRegister>): AuthStores<T, TRegister>
1482
+ ```
1483
+
1484
+ - `client` — Auth client
1485
+
1486
+ **Returns:** Auth stores and actions
1487
+
1488
+ #### `createCapacitorAppStore(options)`
1489
+
1490
+ Create a Svelte store wrapping the Capacitor app coordinator.
1491
+
1492
+ Creates a CapacitorApp instance, subscribes to state changes,
1493
+ and auto-initializes. The returned store is readable and also
1494
+ exposes an `initialize` method for manual re-initialization.
1495
+
1496
+ ```typescript
1497
+ function createCapacitorAppStore(options?: CapacitorAppOptions): CapacitorAppStore
1498
+ ```
1499
+
1500
+ - `options` — Capacitor app options
1501
+
1502
+ **Returns:** A readable store of CapacitorAppState with an initialize method
1503
+
1504
+ #### `createChangePasswordStore()`
1505
+
1506
+ Creates a change password store with async state tracking.
1507
+
1508
+ ```typescript
1509
+ function createChangePasswordStore(): ChangePasswordStore
1510
+ ```
1511
+
1512
+ **Returns:** Change password promise store
1513
+
1514
+ #### `createDeviceStores()`
1515
+
1516
+ Create device stores from the module-level device provider.
1517
+
1518
+ Device information is static (no reactive subscription needed),
1519
+ so this returns plain values rather than Svelte stores.
1520
+
1521
+ ```typescript
1522
+ function createDeviceStores(): {
1523
+ deviceInfo: DeviceInfo
1524
+ screenInfo: ScreenInfo
1525
+ hardwareInfo: HardwareInfo
1526
+ featureSupport: FeatureSupport
1527
+ supports: (feature: keyof FeatureSupport) => boolean
1528
+ isOnline: () => boolean
1529
+ isStandalone: () => boolean
1530
+ language: string
1531
+ languages: string[]
1563
1532
  }
1564
1533
  ```
1565
1534
 
1566
- **Returns:** Push notification stores and actions
1535
+ **Returns:** Device information and utility functions
1567
1536
 
1568
- #### `createPutStore(url, config)`
1537
+ #### `createFormStores(provider, options)`
1569
1538
 
1570
- Creates a PUT request store.
1539
+ Create form stores from a form provider and options.
1571
1540
 
1572
1541
  ```typescript
1573
- function createPutStore(url: string, config?: RequestConfig): HttpStore<T>
1542
+ function createFormStores(provider: FormProvider, options: FormOptions<T>): FormStores<T>
1574
1543
  ```
1575
1544
 
1576
- - `url` — The request endpoint URL.
1577
- - `config` — Optional request configuration such as headers or body data.
1545
+ - `provider` — Form provider instance
1546
+ - `options` — Form creation options
1578
1547
 
1579
- **Returns:** A subscribable HTTP store for the PUT request with execute and reset methods.
1548
+ **Returns:** Form stores and actions
1580
1549
 
1581
- #### `createRouterStores()`
1550
+ #### `createFieldStore(controller, name)`
1582
1551
 
1583
- Create router stores from the router in context.
1552
+ Create a readable store that tracks a single field's state.
1584
1553
 
1585
1554
  ```typescript
1586
- function createRouterStores(): RouterStores
1555
+ function createFieldStore(controller: FormController<T>, name: K): Readable<FieldState<T[K]>>
1587
1556
  ```
1588
1557
 
1589
- **Returns:** Router stores and actions
1558
+ - `controller` — Form controller
1559
+ - `name` — Field name to track
1590
1560
 
1591
- #### `createRouterStoresFromRouter(router)`
1561
+ **Returns:** Readable store of the field state
1592
1562
 
1593
- Create router stores from a specific router.
1563
+ #### `createWatchStore(controller, name)`
1564
+
1565
+ Create a readable store that tracks a single field's value.
1594
1566
 
1595
1567
  ```typescript
1596
- function createRouterStoresFromRouter(router: Router): RouterStores
1568
+ function createWatchStore(controller: FormController<T>, name: K): Readable<T[K]>
1597
1569
  ```
1598
1570
 
1599
- - `router` — Router instance
1571
+ - `controller` — Form controller
1572
+ - `name` — Field name to watch
1600
1573
 
1601
- **Returns:** Router stores and actions
1574
+ **Returns:** Readable store of the field value
1602
1575
 
1603
- #### `createSignupStore()`
1576
+ #### `createHttpStore(method, url, config)`
1604
1577
 
1605
- Creates a signup store with async state tracking.
1578
+ Create an HTTP request store.
1606
1579
 
1607
1580
  ```typescript
1608
- function createSignupStore(): SignupStore<T>
1581
+ function createHttpStore(
1582
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
1583
+ url: string,
1584
+ config?: RequestConfig,
1585
+ ): HttpStore<T>
1609
1586
  ```
1610
1587
 
1611
- **Returns:** Signup promise store
1588
+ - `method` — HTTP method
1589
+ - `url` — Request URL
1590
+ - `config` — Request configuration
1612
1591
 
1613
- #### `createStorageHelpers()`
1592
+ **Returns:** Store with state and actions
1614
1593
 
1615
- Create storage helper functions from context.
1594
+ #### `createGetStore(url, config)`
1595
+
1596
+ Creates a GET request store.
1616
1597
 
1617
1598
  ```typescript
1618
- function createStorageHelpers(): StorageHelpers
1599
+ function createGetStore(url: string, config?: RequestConfig): HttpStore<T>
1619
1600
  ```
1620
1601
 
1621
- **Returns:** Storage functions
1602
+ - `url` — The request endpoint URL.
1603
+ - `config` — Optional request configuration such as headers or params.
1622
1604
 
1623
- #### `createStorageStore(key, defaultValue)`
1605
+ **Returns:** A subscribable HTTP store for the GET request with execute and reset methods.
1624
1606
 
1625
- Create a storage value store.
1607
+ #### `createPostStore(url, config)`
1608
+
1609
+ Creates a POST request store.
1626
1610
 
1627
1611
  ```typescript
1628
- function createStorageStore(key: string, defaultValue?: T): StorageStore<T>
1612
+ function createPostStore(url: string, config?: RequestConfig): HttpStore<T>
1629
1613
  ```
1630
1614
 
1631
- - `key` — Storage key
1632
- - `defaultValue` — Default value if not found
1615
+ - `url` — The request endpoint URL.
1616
+ - `config` — Optional request configuration such as headers or body data.
1633
1617
 
1634
- **Returns:** Store with value and actions
1618
+ **Returns:** A subscribable HTTP store for the POST request with execute and reset methods.
1635
1619
 
1636
- #### `createStorageStoreFromProvider(storage, key, defaultValue)`
1620
+ #### `createPutStore(url, config)`
1637
1621
 
1638
- Create storage store from a specific provider.
1622
+ Creates a PUT request store.
1639
1623
 
1640
1624
  ```typescript
1641
- function createStorageStoreFromProvider(
1642
- storage: StorageProvider,
1643
- key: string,
1644
- defaultValue?: T,
1645
- ): StorageStore<T>
1625
+ function createPutStore(url: string, config?: RequestConfig): HttpStore<T>
1646
1626
  ```
1647
1627
 
1648
- - `storage` — Storage provider
1649
- - `key` — Storage key
1650
- - `defaultValue` — Default value
1628
+ - `url` — The request endpoint URL.
1629
+ - `config` — Optional request configuration such as headers or body data.
1651
1630
 
1652
- **Returns:** Store with value and actions
1631
+ **Returns:** A subscribable HTTP store for the PUT request with execute and reset methods.
1653
1632
 
1654
- #### `createStoreAction(store, action)`
1633
+ #### `createPatchStore(url, config)`
1655
1634
 
1656
- Create a bound action for a store.
1635
+ Creates a PATCH request store.
1657
1636
 
1658
1637
  ```typescript
1659
- function createStoreAction(
1660
- store: MoleculeStore<T>,
1661
- action: (
1662
- setState: MoleculeStore<T>['setState'],
1663
- getState: MoleculeStore<T>['getState'],
1664
- ) => (...args: Args) => R,
1665
- ): (...args: Args) => R
1638
+ function createPatchStore(url: string, config?: RequestConfig): HttpStore<T>
1666
1639
  ```
1667
1640
 
1668
- - `store` — The store
1669
- - `action` — Action creator function
1641
+ - `url` — The request endpoint URL.
1642
+ - `config` — Optional request configuration such as headers or body data.
1670
1643
 
1671
- **Returns:** Bound action
1644
+ **Returns:** A subscribable HTTP store for the PATCH request with execute and reset methods.
1672
1645
 
1673
- #### `createStoreReadable(store)`
1646
+ #### `createDeleteStore(url, config)`
1674
1647
 
1675
- Create a readable Svelte store from a molecule store.
1648
+ Creates a DELETE request store.
1676
1649
 
1677
1650
  ```typescript
1678
- function createStoreReadable(store: MoleculeStore<T>): Readable<T>
1651
+ function createDeleteStore(url: string, config?: RequestConfig): HttpStore<T>
1679
1652
  ```
1680
1653
 
1681
- - `store` — The molecule store
1654
+ - `url` — The request endpoint URL.
1655
+ - `config` — Optional request configuration such as headers or params.
1682
1656
 
1683
- **Returns:** Readable Svelte store
1657
+ **Returns:** A subscribable HTTP store for the DELETE request with execute and reset methods.
1684
1658
 
1685
- #### `createStoreSelector(store, selector)`
1659
+ #### `createHttpStoresFromClient(client)`
1686
1660
 
1687
- Create a derived Svelte store with a selector.
1661
+ Creates HTTP store factory methods bound to a specific client instance.
1688
1662
 
1689
1663
  ```typescript
1690
- function createStoreSelector(store: MoleculeStore<T>, selector: (state: T) => S): Readable<S>
1664
+ function createHttpStoresFromClient(client: HttpClient): HttpStoreFactory
1691
1665
  ```
1692
1666
 
1693
- - `store` — The molecule store
1694
- - `selector` — Selector function
1667
+ - `client` — The HTTP client to use for all created stores.
1695
1668
 
1696
- **Returns:** Derived Svelte store
1669
+ **Returns:** An object with get, post, put, patch, and delete factory methods.
1697
1670
 
1698
- #### `createThemeColorsStore(theme)`
1671
+ #### `createI18nStores()`
1699
1672
 
1700
- Create a derived store that returns just the theme colors.
1673
+ Create i18n stores from the i18n provider in context.
1701
1674
 
1702
1675
  ```typescript
1703
- function createThemeColorsStore(theme: Readable<Theme>): Readable<ThemeColors>
1676
+ function createI18nStores(): I18nStores
1704
1677
  ```
1705
1678
 
1706
- - `theme` — A readable theme store (from createThemeStores or createThemeStoresFromProvider)
1679
+ **Returns:** I18n stores and actions
1707
1680
 
1708
- **Returns:** Readable store of theme colors
1681
+ #### `createI18nStoresFromProvider(provider)`
1709
1682
 
1710
- #### `createThemeStores()`
1683
+ Create i18n stores from a specific provider.
1711
1684
 
1712
- Create theme stores from the theme provider in context.
1685
+ ```typescript
1686
+ function createI18nStoresFromProvider(provider: I18nProvider): I18nStores
1687
+ ```
1688
+
1689
+ - `provider` — I18n provider
1690
+
1691
+ **Returns:** I18n stores and actions
1692
+
1693
+ #### `getLogger(name)`
1694
+
1695
+ Get a logger instance.
1713
1696
 
1714
1697
  ```typescript
1715
- function createThemeStores(): ThemeStores & { colors: Readable<Theme['colors']> }
1698
+ function getLogger(name?: string): Logger
1716
1699
  ```
1717
1700
 
1718
- **Returns:** Theme stores and actions
1701
+ - `name` — Logger name
1719
1702
 
1720
- #### `createThemeStoresFromProvider(provider)`
1703
+ **Returns:** Logger instance
1721
1704
 
1722
- Create theme stores from a specific theme provider.
1705
+ #### `createLogger(config)`
1706
+
1707
+ Create a logger with custom configuration.
1723
1708
 
1724
1709
  ```typescript
1725
- function createThemeStoresFromProvider(provider: ThemeProvider): ThemeStores
1710
+ function createLogger(config: LoggerConfig): Logger
1726
1711
  ```
1727
1712
 
1728
- - `provider` — Theme provider
1713
+ - `config` — Logger configuration
1729
1714
 
1730
- **Returns:** Theme stores and actions
1715
+ **Returns:** Logger instance
1731
1716
 
1732
- #### `createVersionStores()`
1717
+ #### `getRootLogger()`
1733
1718
 
1734
- Create version stores from the module-level version provider.
1719
+ Get the root logger.
1735
1720
 
1736
1721
  ```typescript
1737
- function createVersionStores(): {
1738
- state: Readable<VersionState>
1739
- isUpdateAvailable: Readable<boolean>
1740
- isChecking: Readable<boolean>
1741
- isServiceWorkerWaiting: Readable<boolean>
1742
- newVersion: Readable<string | undefined>
1743
- checkForUpdates: () => Promise<boolean>
1744
- applyUpdate: (options?: { force?: boolean }) => void
1745
- dismissUpdate: () => void
1746
- startPeriodicChecks: (options?: UpdateCheckOptions) => void
1747
- stopPeriodicChecks: () => void
1748
- }
1722
+ function getRootLogger(): Logger
1749
1723
  ```
1750
1724
 
1751
- **Returns:** Version stores and actions
1725
+ **Returns:** Root logger instance
1752
1726
 
1753
- #### `createWatchStore(controller, name)`
1727
+ #### `getChildLogger(name, context)`
1754
1728
 
1755
- Create a readable store that tracks a single field's value.
1729
+ Create a child logger with additional context.
1756
1730
 
1757
1731
  ```typescript
1758
- function createWatchStore(controller: FormController<T>, name: K): Readable<T[K]>
1732
+ function getChildLogger(name: string, context: Record<string, unknown>): Logger
1759
1733
  ```
1760
1734
 
1761
- - `controller` — Form controller
1762
- - `name` — Field name to watch
1735
+ - `name` — Parent logger name
1736
+ - `context` — Additional context
1763
1737
 
1764
- **Returns:** Readable store of the field value
1738
+ **Returns:** Child logger instance
1765
1739
 
1766
- #### `getAuthClient()`
1740
+ #### `createLoggerHelpers()`
1767
1741
 
1768
- Gets the auth client from Svelte context.
1742
+ Create logger helpers from context.
1769
1743
 
1770
1744
  ```typescript
1771
- function getAuthClient(): AuthClient<T>
1745
+ function createLoggerHelpers(): LoggerHelpers
1772
1746
  ```
1773
1747
 
1774
- **Returns:** The auth client instance.
1748
+ **Returns:** Logger helper functions
1749
+
1750
+ #### `createLoggerHelpersFromProvider(provider)`
1751
+
1752
+ Create logger helpers from a specific provider.
1753
+
1754
+ ```typescript
1755
+ function createLoggerHelpersFromProvider(provider: LoggerProvider): LoggerHelpers
1756
+ ```
1757
+
1758
+ - `provider` — Logger provider
1759
+
1760
+ **Returns:** Logger helper functions
1761
+
1762
+ #### `createLoginStore()`
1763
+
1764
+ Creates a login store with async state tracking.
1765
+
1766
+ ```typescript
1767
+ function createLoginStore(): LoginStore<T>
1768
+ ```
1769
+
1770
+ **Returns:** Login promise store
1771
+
1772
+ #### `createOAuthHelpers(options)`
1773
+
1774
+ Creates OAuth helpers for provider-based authentication flows.
1775
1775
 
1776
- #### `getChildLogger(name, context)`
1776
+ When created in a browser, automatically handles OAuth callbacks by
1777
+ detecting `code` and `state` URL parameters and exchanging them for a
1778
+ session (a guarded no-op when there is no callback code in the URL).
1777
1779
 
1778
- Create a child logger with additional context.
1780
+ Session establishment: the exchange result is applied to the resolved auth
1781
+ client (an explicit `options.authClient`, else the Svelte-context client
1782
+ when created during component initialization). When NO client is available,
1783
+ the server has already established the httpOnly-cookie session via the
1784
+ exchange, so a user-carrying response still counts as success —
1785
+ `options.onSuccess` fires; a response with no user fires `options.onError`.
1779
1786
 
1780
1787
  ```typescript
1781
- function getChildLogger(name: string, context: Record<string, unknown>): Logger
1788
+ function createOAuthHelpers(options?: OAuthOptions): OAuthHelpers
1782
1789
  ```
1783
1790
 
1784
- - `name` — Parent logger name
1785
- - `context` — Additional context
1791
+ - `options` — OAuth configuration (base URL, providers, endpoint paths, callbacks, auth client).
1786
1792
 
1787
- **Returns:** Child logger instance
1793
+ **Returns:** An object containing a readable providers store, URL builder, redirect function, and callback handler.
1788
1794
 
1789
- #### `getHttpClient()`
1795
+ #### `createPasswordResetStores()`
1790
1796
 
1791
- Gets the HTTP client from Svelte context.
1797
+ Creates password reset stores with async state tracking.
1792
1798
 
1793
1799
  ```typescript
1794
- function getHttpClient(): HttpClient
1800
+ function createPasswordResetStores(): PasswordResetStores
1795
1801
  ```
1796
1802
 
1797
- **Returns:** The HTTP client instance.
1803
+ **Returns:** Password reset stores for request and confirm steps
1798
1804
 
1799
- #### `getI18nProvider()`
1805
+ #### `createPlatformStores()`
1800
1806
 
1801
- Gets the i18n provider from Svelte context.
1807
+ Create platform stores from the module-level platform info.
1808
+
1809
+ Platform information is static (no reactive subscription needed),
1810
+ so this returns plain values rather than Svelte stores.
1802
1811
 
1803
1812
  ```typescript
1804
- function getI18nProvider(): I18nProvider
1813
+ function createPlatformStores(): {
1814
+ platform: Platform
1815
+ isNative: boolean
1816
+ isMobile: boolean
1817
+ isDesktop: boolean
1818
+ isWeb: boolean
1819
+ isDevelopment: boolean
1820
+ isProduction: boolean
1821
+ isPlatform: (...platforms: Platform[]) => boolean
1822
+ }
1805
1823
  ```
1806
1824
 
1807
- **Returns:** The i18n provider instance.
1825
+ **Returns:** Platform information and utility functions
1808
1826
 
1809
- #### `getLogger(name)`
1827
+ #### `createPromiseStore(asyncFn)`
1810
1828
 
1811
- Get a logger instance.
1829
+ Creates a store that tracks async function state.
1812
1830
 
1813
1831
  ```typescript
1814
- function getLogger(name?: string): Logger
1832
+ function createPromiseStore(asyncFn: T): PromiseStore<Awaited<ReturnType<T>>>
1815
1833
  ```
1816
1834
 
1817
- - `name` — Logger name
1835
+ - `asyncFn` — The async function to track
1818
1836
 
1819
- **Returns:** Logger instance
1837
+ **Returns:** Promise store with subscribe, call, cancel, and reset
1820
1838
 
1821
- #### `getLoggerProvider()`
1839
+ #### `createPushStores()`
1822
1840
 
1823
- Gets the logger provider from Svelte context.
1841
+ Create push notification stores from the module-level push provider.
1824
1842
 
1825
1843
  ```typescript
1826
- function getLoggerProvider(): LoggerProvider
1844
+ function createPushStores(): {
1845
+ permission: Readable<PermissionStatus | null>
1846
+ token: Readable<PushToken | null>
1847
+ checkPermission: () => Promise<PermissionStatus>
1848
+ requestPermission: () => Promise<PermissionStatus>
1849
+ register: (options?: PushRegisterOptions) => Promise<PushToken>
1850
+ unregister: () => Promise<void>
1851
+ onNotificationReceived: (listener: NotificationReceivedListener) => () => void
1852
+ onNotificationAction: (listener: NotificationActionListener) => () => void
1853
+ onTokenChange: (listener: TokenChangeListener) => () => void
1854
+ setBadge: (count: number) => Promise<void>
1855
+ clearBadge: () => Promise<void>
1856
+ }
1827
1857
  ```
1828
1858
 
1829
- **Returns:** The logger provider instance.
1859
+ **Returns:** Push notification stores and actions
1830
1860
 
1831
- #### `getRootLogger()`
1861
+ #### `createRouterStores()`
1832
1862
 
1833
- Get the root logger.
1863
+ Create router stores from the router in context.
1834
1864
 
1835
1865
  ```typescript
1836
- function getRootLogger(): Logger
1866
+ function createRouterStores(): RouterStores
1837
1867
  ```
1838
1868
 
1839
- **Returns:** Root logger instance
1869
+ **Returns:** Router stores and actions
1840
1870
 
1841
- #### `getRouter()`
1871
+ #### `createIsActiveStore(location, router, path, exact)`
1842
1872
 
1843
- Gets the router from Svelte context.
1873
+ Create a derived store that checks if a path is active.
1844
1874
 
1845
1875
  ```typescript
1846
- function getRouter(): Router
1876
+ function createIsActiveStore(
1877
+ location: Readable<RouteLocation>,
1878
+ router: Router,
1879
+ path: string,
1880
+ exact?: boolean,
1881
+ ): Readable<boolean>
1847
1882
  ```
1848
1883
 
1849
- **Returns:** The router instance.
1884
+ - `location` — A readable location store (from createRouterStores or createRouterStoresFromRouter)
1885
+ - `router` — Router instance (for isActive check)
1886
+ - `path` — Path to check
1887
+ - `exact` — Whether to require exact match (default: false)
1850
1888
 
1851
- #### `getSetStore(store)`
1889
+ **Returns:** Readable store of whether the path is active
1852
1890
 
1853
- Get the setState function from a molecule store.
1891
+ #### `createRouterStoresFromRouter(router)`
1892
+
1893
+ Create router stores from a specific router.
1854
1894
 
1855
1895
  ```typescript
1856
- function getSetStore(
1857
- store: MoleculeStore<T>,
1858
- ): (partial: Partial<T> | ((state: T) => Partial<T>)) => void
1896
+ function createRouterStoresFromRouter(router: Router): RouterStores
1859
1897
  ```
1860
1898
 
1861
- - `store` — The molecule store
1899
+ - `router` — Router instance
1862
1900
 
1863
- **Returns:** setState function
1901
+ **Returns:** Router stores and actions
1864
1902
 
1865
- #### `getStateProvider()`
1903
+ #### `createSignupStore()`
1866
1904
 
1867
- Gets the state provider from Svelte context.
1905
+ Creates a signup store with async state tracking.
1868
1906
 
1869
1907
  ```typescript
1870
- function getStateProvider(): StateProvider
1908
+ function createSignupStore(): SignupStore<T>
1871
1909
  ```
1872
1910
 
1873
- **Returns:** The state provider instance.
1911
+ **Returns:** Signup promise store
1874
1912
 
1875
- #### `getStorageProvider()`
1913
+ #### `createStoreReadable(store)`
1876
1914
 
1877
- Gets the storage provider from Svelte context.
1915
+ Create a readable Svelte store from a molecule store.
1878
1916
 
1879
1917
  ```typescript
1880
- function getStorageProvider(): StorageProvider
1918
+ function createStoreReadable(store: MoleculeStore<T>): Readable<T>
1881
1919
  ```
1882
1920
 
1883
- **Returns:** The storage provider instance.
1921
+ - `store` — The molecule store
1884
1922
 
1885
- #### `getThemeProvider()`
1923
+ **Returns:** Readable Svelte store
1886
1924
 
1887
- Gets the theme provider from Svelte context.
1925
+ #### `createStoreSelector(store, selector)`
1926
+
1927
+ Create a derived Svelte store with a selector.
1888
1928
 
1889
1929
  ```typescript
1890
- function getThemeProvider(): ThemeProvider
1930
+ function createStoreSelector(store: MoleculeStore<T>, selector: (state: T) => S): Readable<S>
1891
1931
  ```
1892
1932
 
1893
- **Returns:** The theme provider instance.
1933
+ - `store` — The molecule store
1934
+ - `selector` — Selector function
1894
1935
 
1895
- #### `setAuthContext(client)`
1936
+ **Returns:** Derived Svelte store
1896
1937
 
1897
- Sets the auth context.
1938
+ #### `getSetStore(store)`
1939
+
1940
+ Get the setState function from a molecule store.
1898
1941
 
1899
1942
  ```typescript
1900
- function setAuthContext(client: AuthClient<T>): void
1943
+ function getSetStore(
1944
+ store: MoleculeStore<T>,
1945
+ ): (partial: Partial<T> | ((state: T) => Partial<T>)) => void
1901
1946
  ```
1902
1947
 
1903
- - `client` — The auth client to store in Svelte context.
1948
+ - `store` — The molecule store
1904
1949
 
1905
- #### `setHttpContext(client)`
1950
+ **Returns:** setState function
1906
1951
 
1907
- Sets the HTTP context.
1952
+ #### `createStoreAction(store, action)`
1953
+
1954
+ Create a bound action for a store.
1908
1955
 
1909
1956
  ```typescript
1910
- function setHttpContext(client: HttpClient): void
1957
+ function createStoreAction(
1958
+ store: MoleculeStore<T>,
1959
+ action: (
1960
+ setState: MoleculeStore<T>['setState'],
1961
+ getState: MoleculeStore<T>['getState'],
1962
+ ) => (...args: Args) => R,
1963
+ ): (...args: Args) => R
1911
1964
  ```
1912
1965
 
1913
- - `client` — The HTTP client to store in Svelte context.
1966
+ - `store` — The store
1967
+ - `action` — Action creator function
1914
1968
 
1915
- #### `setI18nContext(provider)`
1969
+ **Returns:** Bound action
1916
1970
 
1917
- Sets the i18n context.
1971
+ #### `createStorageStore(key, defaultValue)`
1972
+
1973
+ Create a storage value store.
1918
1974
 
1919
1975
  ```typescript
1920
- function setI18nContext(provider: I18nProvider): void
1976
+ function createStorageStore(key: string, defaultValue?: T): StorageStore<T>
1921
1977
  ```
1922
1978
 
1923
- - `provider` — The i18n provider to store in Svelte context.
1979
+ - `key` — Storage key
1980
+ - `defaultValue` — Default value if not found
1924
1981
 
1925
- #### `setLoggerContext(provider)`
1982
+ **Returns:** Store with value and actions
1926
1983
 
1927
- Sets the logger context.
1984
+ #### `createStorageHelpers()`
1985
+
1986
+ Create storage helper functions from context.
1928
1987
 
1929
1988
  ```typescript
1930
- function setLoggerContext(provider: LoggerProvider): void
1989
+ function createStorageHelpers(): StorageHelpers
1931
1990
  ```
1932
1991
 
1933
- - `provider` — The logger provider to store in Svelte context.
1934
-
1935
- #### `setMoleculeContext(config)`
1992
+ **Returns:** Storage functions
1936
1993
 
1937
- Set all molecule providers in Svelte context.
1994
+ #### `createStorageStoreFromProvider(storage, key, defaultValue)`
1938
1995
 
1939
- Call this in your root layout/component.
1996
+ Create storage store from a specific provider.
1940
1997
 
1941
1998
  ```typescript
1942
- function setMoleculeContext(config: MoleculeConfig): void
1999
+ function createStorageStoreFromProvider(
2000
+ storage: StorageProvider,
2001
+ key: string,
2002
+ defaultValue?: T,
2003
+ ): StorageStore<T>
1943
2004
  ```
1944
2005
 
1945
- - `config` — Provider instances to register (state, auth, theme, router, i18n, http, storage, logger).
2006
+ - `storage` — Storage provider
2007
+ - `key` — Storage key
2008
+ - `defaultValue` — Default value
1946
2009
 
1947
- #### `setRouterContext(router)`
2010
+ **Returns:** Store with value and actions
1948
2011
 
1949
- Sets the router context.
2012
+ #### `createThemeStores()`
2013
+
2014
+ Create theme stores from the theme provider in context.
1950
2015
 
1951
2016
  ```typescript
1952
- function setRouterContext(router: Router): void
2017
+ function createThemeStores(): ThemeStores & { colors: Readable<Theme['colors']> }
1953
2018
  ```
1954
2019
 
1955
- - `router` — The router instance to store in Svelte context.
2020
+ **Returns:** Theme stores and actions
1956
2021
 
1957
- #### `setStateContext(provider)`
2022
+ #### `createThemeColorsStore(theme)`
1958
2023
 
1959
- Sets the state context.
2024
+ Create a derived store that returns just the theme colors.
1960
2025
 
1961
2026
  ```typescript
1962
- function setStateContext(provider: StateProvider): void
2027
+ function createThemeColorsStore(theme: Readable<Theme>): Readable<ThemeColors>
1963
2028
  ```
1964
2029
 
1965
- - `provider` — The state provider to store in Svelte context.
2030
+ - `theme` — A readable theme store (from createThemeStores or createThemeStoresFromProvider)
1966
2031
 
1967
- #### `setStorageContext(provider)`
2032
+ **Returns:** Readable store of theme colors
1968
2033
 
1969
- Sets the storage context.
2034
+ #### `createThemeStoresFromProvider(provider)`
2035
+
2036
+ Create theme stores from a specific theme provider.
1970
2037
 
1971
2038
  ```typescript
1972
- function setStorageContext(provider: StorageProvider): void
2039
+ function createThemeStoresFromProvider(provider: ThemeProvider): ThemeStores
1973
2040
  ```
1974
2041
 
1975
- - `provider` — The storage provider to store in Svelte context.
2042
+ - `provider` — Theme provider
1976
2043
 
1977
- #### `setThemeContext(provider)`
2044
+ **Returns:** Theme stores and actions
1978
2045
 
1979
- Sets the theme context.
2046
+ #### `createVersionStores()`
2047
+
2048
+ Create version stores from the module-level version provider.
1980
2049
 
1981
2050
  ```typescript
1982
- function setThemeContext(provider: ThemeProvider): void
2051
+ function createVersionStores(): {
2052
+ state: Readable<VersionState>
2053
+ isUpdateAvailable: Readable<boolean>
2054
+ isChecking: Readable<boolean>
2055
+ isServiceWorkerWaiting: Readable<boolean>
2056
+ newVersion: Readable<string | undefined>
2057
+ checkForUpdates: () => Promise<boolean>
2058
+ applyUpdate: (options?: { force?: boolean }) => void
2059
+ dismissUpdate: () => void
2060
+ startPeriodicChecks: (options?: UpdateCheckOptions) => void
2061
+ stopPeriodicChecks: () => void
2062
+ }
1983
2063
  ```
1984
2064
 
1985
- - `provider` — The theme provider to store in Svelte context.
2065
+ **Returns:** Version stores and actions
1986
2066
 
1987
2067
  ## Injection Notes
1988
2068