@molecule/app-svelte 1.0.1 → 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-08-04T01:52:54.164Z
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,
@@ -1111,869 +1054,1015 @@ interface ThemeProvider {
1111
1054
  * support multiple themes.
1112
1055
  */
1113
1056
  getThemes?(): Theme[]
1057
+ /**
1058
+ * Returns the theme a render WITHOUT a browser produces — a server or
1059
+ * build-time render, which has no storage and no `prefers-color-scheme`
1060
+ * to read. A hydrating client renders this theme first, so its markup
1061
+ * matches what the server sent, and switches to `getTheme()` right
1062
+ * after. Optional — a provider whose theme cannot differ between the two
1063
+ * need not implement it.
1064
+ */
1065
+ getServerTheme?(): Theme
1114
1066
  }
1115
1067
  ```
1116
1068
 
1117
- #### `Writable`
1069
+ #### `Theme`
1118
1070
 
1119
- Writable interface for both updating and subscribing.
1071
+ Complete theme definition.
1120
1072
 
1121
1073
  ```typescript
1122
- interface Writable<T> extends Readable<T> {
1123
- /**
1124
- * Set value and inform subscribers.
1125
- * @param value to set
1126
- */
1127
- set(this: void, value: T): void
1128
-
1129
- /**
1130
- * Update value using callback and inform subscribers.
1131
- * @param updater callback
1132
- */
1133
- 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
1134
1085
  }
1135
1086
  ```
1136
1087
 
1137
- ### Types
1138
-
1139
- #### `CapacitorAppStore`
1088
+ #### `AsyncStateStore`
1140
1089
 
1141
- Return type for the Capacitor app store.
1090
+ Async state store.
1142
1091
 
1143
1092
  ```typescript
1144
- type CapacitorAppStore = Readable<CapacitorAppState> & {
1145
- 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
1146
1099
  }
1147
1100
  ```
1148
1101
 
1149
- #### `ChangePasswordStore`
1102
+ #### `OAuthOptions`
1150
1103
 
1151
- Change password store type.
1104
+ OAuth configuration options.
1152
1105
 
1153
1106
  ```typescript
1154
- 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
+ }
1155
1128
  ```
1156
1129
 
1157
- #### `LoginStore`
1130
+ #### `OAuthHelpers`
1158
1131
 
1159
- Login store type.
1132
+ OAuth helpers returned by {@link createOAuthHelpers}.
1160
1133
 
1161
1134
  ```typescript
1162
- 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
+ }
1163
1151
  ```
1164
1152
 
1165
- #### `QueryParams`
1153
+ #### `PasswordResetStores`
1166
1154
 
1167
- URL query string parameter map (single values or arrays for repeated keys).
1155
+ Password reset stores.
1168
1156
 
1169
1157
  ```typescript
1170
- 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
+ }
1171
1171
  ```
1172
1172
 
1173
- #### `RouteParams`
1173
+ #### `PromiseStore`
1174
1174
 
1175
- URL path parameter key-value map extracted from dynamic route segments (e.g. `{ id: '123' }`).
1175
+ Promise store with action methods.
1176
1176
 
1177
1177
  ```typescript
1178
- 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
+ }
1179
1183
  ```
1180
1184
 
1181
- #### `SignupStore`
1185
+ #### `MoleculeConfig`
1182
1186
 
1183
- Signup store type.
1187
+ Configuration for molecule Svelte context.
1184
1188
 
1185
1189
  ```typescript
1186
- 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
+ }
1187
1200
  ```
1188
1201
 
1189
- ### Functions
1190
-
1191
- #### `createAsyncState(initialValue)`
1202
+ #### `HttpState`
1192
1203
 
1193
- Creates a writable store with async-capable setState and extendState.
1204
+ State for async HTTP operations.
1194
1205
 
1195
1206
  ```typescript
1196
- function createAsyncState(initialValue: T): AsyncStateStore<T>
1207
+ interface HttpState<T> {
1208
+ data: T | null
1209
+ loading: boolean
1210
+ error: Error | null
1211
+ }
1197
1212
  ```
1198
1213
 
1199
- - `initialValue` — The initial state value
1200
-
1201
- **Returns:** The created instance.
1214
+ #### `StorageValueState`
1202
1215
 
1203
- #### `createAuthStores()`
1204
-
1205
- Create auth stores from the auth client in context.
1216
+ State for async storage values.
1206
1217
 
1207
1218
  ```typescript
1208
- function createAuthStores(): AuthStores<T> & { error: Readable<string | null> }
1219
+ interface StorageValueState<T> {
1220
+ value: T | undefined
1221
+ loading: boolean
1222
+ error: Error | null
1223
+ }
1209
1224
  ```
1210
1225
 
1211
- **Returns:** Auth stores and actions
1212
-
1213
- #### `createAuthStoresFromClient(client)`
1226
+ ### Types
1214
1227
 
1215
- Create auth stores from a specific auth client.
1228
+ #### `RouteParams`
1216
1229
 
1217
- 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' }`).
1218
1231
 
1219
1232
  ```typescript
1220
- function createAuthStoresFromClient(client: AuthClient<T>): AuthStores<T>
1233
+ type RouteParams = Record<string, string>
1221
1234
  ```
1222
1235
 
1223
- - `client` — Auth client
1236
+ #### `QueryParams`
1224
1237
 
1225
- **Returns:** Auth stores and actions
1238
+ URL query string parameter map (single values or arrays for repeated keys).
1226
1239
 
1227
- #### `createCapacitorAppStore(options)`
1240
+ ```typescript
1241
+ type QueryParams = Record<string, string | string[] | undefined>
1242
+ ```
1228
1243
 
1229
- Create a Svelte store wrapping the Capacitor app coordinator.
1244
+ #### `CapacitorAppStore`
1230
1245
 
1231
- Creates a CapacitorApp instance, subscribes to state changes,
1232
- and auto-initializes. The returned store is readable and also
1233
- exposes an `initialize` method for manual re-initialization.
1246
+ Return type for the Capacitor app store.
1234
1247
 
1235
1248
  ```typescript
1236
- function createCapacitorAppStore(options?: CapacitorAppOptions): CapacitorAppStore
1249
+ type CapacitorAppStore = Readable<CapacitorAppState> & {
1250
+ initialize: () => Promise<void>
1251
+ }
1237
1252
  ```
1238
1253
 
1239
- - `options` — Capacitor app options
1254
+ #### `ChangePasswordStore`
1240
1255
 
1241
- **Returns:** A readable store of CapacitorAppState with an initialize method
1256
+ Change password store type.
1242
1257
 
1243
- #### `createChangePasswordStore()`
1258
+ ```typescript
1259
+ type ChangePasswordStore = PromiseStore<void>
1260
+ ```
1244
1261
 
1245
- Creates a change password store with async state tracking.
1262
+ #### `LoginStore`
1263
+
1264
+ Login store type.
1246
1265
 
1247
1266
  ```typescript
1248
- function createChangePasswordStore(): ChangePasswordStore
1267
+ type LoginStore<T = unknown> = PromiseStore<AuthResult<T>>
1249
1268
  ```
1250
1269
 
1251
- **Returns:** Change password promise store
1252
-
1253
- #### `createDeleteStore(url, config)`
1270
+ #### `SignupStore`
1254
1271
 
1255
- Creates a DELETE request store.
1272
+ Signup store type.
1256
1273
 
1257
1274
  ```typescript
1258
- function createDeleteStore(url: string, config?: RequestConfig): HttpStore<T>
1275
+ type SignupStore<T = unknown> = PromiseStore<AuthResult<T>>
1259
1276
  ```
1260
1277
 
1261
- - `url` — The request endpoint URL.
1262
- - `config` — Optional request configuration such as headers or params.
1263
-
1264
- **Returns:** A subscribable HTTP store for the DELETE request with execute and reset methods.
1278
+ ### Functions
1265
1279
 
1266
- #### `createDeviceStores()`
1280
+ #### `setMoleculeContext(config)`
1267
1281
 
1268
- Create device stores from the module-level device provider.
1282
+ Set all molecule providers in Svelte context.
1269
1283
 
1270
- Device information is static (no reactive subscription needed),
1271
- so this returns plain values rather than Svelte stores.
1284
+ Call this in your root layout/component.
1272
1285
 
1273
1286
  ```typescript
1274
- function createDeviceStores(): {
1275
- deviceInfo: DeviceInfo
1276
- screenInfo: ScreenInfo
1277
- hardwareInfo: HardwareInfo
1278
- featureSupport: FeatureSupport
1279
- supports: (feature: keyof FeatureSupport) => boolean
1280
- isOnline: () => boolean
1281
- isStandalone: () => boolean
1282
- language: string
1283
- languages: string[]
1284
- }
1287
+ function setMoleculeContext(config: MoleculeConfig): void
1285
1288
  ```
1286
1289
 
1287
- **Returns:** Device information and utility functions
1290
+ - `config` — Provider instances to register (state, auth, theme, router, i18n, http, storage, logger).
1288
1291
 
1289
- #### `createFieldStore(controller, name)`
1292
+ #### `setStateContext(provider)`
1290
1293
 
1291
- Create a readable store that tracks a single field's state.
1294
+ Sets the state context.
1292
1295
 
1293
1296
  ```typescript
1294
- function createFieldStore(controller: FormController<T>, name: K): Readable<FieldState<T[K]>>
1297
+ function setStateContext(provider: StateProvider): void
1295
1298
  ```
1296
1299
 
1297
- - `controller` — Form controller
1298
- - `name` — Field name to track
1299
-
1300
- **Returns:** Readable store of the field state
1300
+ - `provider` — The state provider to store in Svelte context.
1301
1301
 
1302
- #### `createFormStores(provider, options)`
1302
+ #### `setAuthContext(client)`
1303
1303
 
1304
- Create form stores from a form provider and options.
1304
+ Sets the auth context.
1305
1305
 
1306
1306
  ```typescript
1307
- function createFormStores(provider: FormProvider, options: FormOptions<T>): FormStores<T>
1307
+ function setAuthContext(client: AuthClient<T, Record<never, never>>): void
1308
1308
  ```
1309
1309
 
1310
- - `provider` — Form provider instance
1311
- - `options` — Form creation options
1312
-
1313
- **Returns:** Form stores and actions
1310
+ - `client` — The auth client to store in Svelte context.
1314
1311
 
1315
- #### `createGetStore(url, config)`
1312
+ #### `setThemeContext(provider)`
1316
1313
 
1317
- Creates a GET request store.
1314
+ Sets the theme context.
1318
1315
 
1319
1316
  ```typescript
1320
- function createGetStore(url: string, config?: RequestConfig): HttpStore<T>
1317
+ function setThemeContext(provider: ThemeProvider): void
1321
1318
  ```
1322
1319
 
1323
- - `url` — The request endpoint URL.
1324
- - `config` — Optional request configuration such as headers or params.
1325
-
1326
- **Returns:** A subscribable HTTP store for the GET request with execute and reset methods.
1320
+ - `provider` — The theme provider to store in Svelte context.
1327
1321
 
1328
- #### `createHttpStore(method, url, config)`
1322
+ #### `setRouterContext(router)`
1329
1323
 
1330
- Create an HTTP request store.
1324
+ Sets the router context.
1331
1325
 
1332
1326
  ```typescript
1333
- function createHttpStore(
1334
- method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
1335
- url: string,
1336
- config?: RequestConfig,
1337
- ): HttpStore<T>
1327
+ function setRouterContext(router: Router): void
1338
1328
  ```
1339
1329
 
1340
- - `method` — HTTP method
1341
- - `url` — Request URL
1342
- - `config` — Request configuration
1343
-
1344
- **Returns:** Store with state and actions
1330
+ - `router` — The router instance to store in Svelte context.
1345
1331
 
1346
- #### `createHttpStoresFromClient(client)`
1332
+ #### `setI18nContext(provider)`
1347
1333
 
1348
- Creates HTTP store factory methods bound to a specific client instance.
1334
+ Sets the i18n context.
1349
1335
 
1350
1336
  ```typescript
1351
- function createHttpStoresFromClient(client: HttpClient): HttpStoreFactory
1337
+ function setI18nContext(provider: I18nProvider): void
1352
1338
  ```
1353
1339
 
1354
- - `client` — The HTTP client to use for all created stores.
1355
-
1356
- **Returns:** An object with get, post, put, patch, and delete factory methods.
1340
+ - `provider` — The i18n provider to store in Svelte context.
1357
1341
 
1358
- #### `createI18nStores()`
1342
+ #### `setHttpContext(client)`
1359
1343
 
1360
- Create i18n stores from the i18n provider in context.
1344
+ Sets the HTTP context.
1361
1345
 
1362
1346
  ```typescript
1363
- function createI18nStores(): I18nStores
1347
+ function setHttpContext(client: HttpClient): void
1364
1348
  ```
1365
1349
 
1366
- **Returns:** I18n stores and actions
1350
+ - `client` — The HTTP client to store in Svelte context.
1367
1351
 
1368
- #### `createI18nStoresFromProvider(provider)`
1352
+ #### `setStorageContext(provider)`
1369
1353
 
1370
- Create i18n stores from a specific provider.
1354
+ Sets the storage context.
1371
1355
 
1372
1356
  ```typescript
1373
- function createI18nStoresFromProvider(provider: I18nProvider): I18nStores
1357
+ function setStorageContext(provider: StorageProvider): void
1374
1358
  ```
1375
1359
 
1376
- - `provider` — I18n provider
1377
-
1378
- **Returns:** I18n stores and actions
1360
+ - `provider` — The storage provider to store in Svelte context.
1379
1361
 
1380
- #### `createIsActiveStore(location, router, path, exact)`
1362
+ #### `setLoggerContext(provider)`
1381
1363
 
1382
- Create a derived store that checks if a path is active.
1364
+ Sets the logger context.
1383
1365
 
1384
1366
  ```typescript
1385
- function createIsActiveStore(
1386
- location: Readable<RouteLocation>,
1387
- router: Router,
1388
- path: string,
1389
- exact?: boolean,
1390
- ): Readable<boolean>
1367
+ function setLoggerContext(provider: LoggerProvider): void
1391
1368
  ```
1392
1369
 
1393
- - `location` — A readable location store (from createRouterStores or createRouterStoresFromRouter)
1394
- - `router` — Router instance (for isActive check)
1395
- - `path` — Path to check
1396
- - `exact` — Whether to require exact match (default: false)
1397
-
1398
- **Returns:** Readable store of whether the path is active
1370
+ - `provider` — The logger provider to store in Svelte context.
1399
1371
 
1400
- #### `createLogger(config)`
1372
+ #### `getStateProvider()`
1401
1373
 
1402
- Create a logger with custom configuration.
1374
+ Gets the state provider from Svelte context.
1403
1375
 
1404
1376
  ```typescript
1405
- function createLogger(config: LoggerConfig): Logger
1377
+ function getStateProvider(): StateProvider
1406
1378
  ```
1407
1379
 
1408
- - `config` — Logger configuration
1409
-
1410
- **Returns:** Logger instance
1380
+ **Returns:** The state provider instance.
1411
1381
 
1412
- #### `createLoggerHelpers()`
1382
+ #### `getAuthClient()`
1413
1383
 
1414
- Create logger helpers from context.
1384
+ Gets the auth client from Svelte context.
1415
1385
 
1416
1386
  ```typescript
1417
- function createLoggerHelpers(): LoggerHelpers
1387
+ function getAuthClient(): AuthClient<T, TRegister>
1418
1388
  ```
1419
1389
 
1420
- **Returns:** Logger helper functions
1390
+ **Returns:** The auth client instance.
1421
1391
 
1422
- #### `createLoggerHelpersFromProvider(provider)`
1392
+ #### `getThemeProvider()`
1423
1393
 
1424
- Create logger helpers from a specific provider.
1394
+ Gets the theme provider from Svelte context.
1425
1395
 
1426
1396
  ```typescript
1427
- function createLoggerHelpersFromProvider(provider: LoggerProvider): LoggerHelpers
1397
+ function getThemeProvider(): ThemeProvider
1428
1398
  ```
1429
1399
 
1430
- - `provider` — Logger provider
1431
-
1432
- **Returns:** Logger helper functions
1400
+ **Returns:** The theme provider instance.
1433
1401
 
1434
- #### `createLoginStore()`
1402
+ #### `getRouter()`
1435
1403
 
1436
- Creates a login store with async state tracking.
1404
+ Gets the router from Svelte context.
1437
1405
 
1438
1406
  ```typescript
1439
- function createLoginStore(): LoginStore<T>
1407
+ function getRouter(): Router
1440
1408
  ```
1441
1409
 
1442
- **Returns:** Login promise store
1443
-
1444
- #### `createOAuthHelpers(options)`
1445
-
1446
- Creates OAuth helpers for provider-based authentication flows.
1410
+ **Returns:** The router instance.
1447
1411
 
1448
- When created in a browser, automatically handles OAuth callbacks by
1449
- detecting `code` and `state` URL parameters and exchanging them for a
1450
- session (a guarded no-op when there is no callback code in the URL).
1412
+ #### `getI18nProvider()`
1451
1413
 
1452
- Session establishment: the exchange result is applied to the resolved auth
1453
- client (an explicit `options.authClient`, else the Svelte-context client
1454
- when created during component initialization). When NO client is available,
1455
- the server has already established the httpOnly-cookie session via the
1456
- exchange, so a user-carrying response still counts as success —
1457
- `options.onSuccess` fires; a response with no user fires `options.onError`.
1414
+ Gets the i18n provider from Svelte context.
1458
1415
 
1459
1416
  ```typescript
1460
- function createOAuthHelpers(options?: OAuthOptions): OAuthHelpers
1417
+ function getI18nProvider(): I18nProvider
1461
1418
  ```
1462
1419
 
1463
- - `options` — OAuth configuration (base URL, providers, endpoint paths, callbacks, auth client).
1464
-
1465
- **Returns:** An object containing a readable providers store, URL builder, redirect function, and callback handler.
1420
+ **Returns:** The i18n provider instance.
1466
1421
 
1467
- #### `createPasswordResetStores()`
1422
+ #### `getHttpClient()`
1468
1423
 
1469
- Creates password reset stores with async state tracking.
1424
+ Gets the HTTP client from Svelte context.
1470
1425
 
1471
1426
  ```typescript
1472
- function createPasswordResetStores(): PasswordResetStores
1427
+ function getHttpClient(): HttpClient
1473
1428
  ```
1474
1429
 
1475
- **Returns:** Password reset stores for request and confirm steps
1430
+ **Returns:** The HTTP client instance.
1476
1431
 
1477
- #### `createPatchStore(url, config)`
1432
+ #### `getStorageProvider()`
1478
1433
 
1479
- Creates a PATCH request store.
1434
+ Gets the storage provider from Svelte context.
1480
1435
 
1481
1436
  ```typescript
1482
- function createPatchStore(url: string, config?: RequestConfig): HttpStore<T>
1437
+ function getStorageProvider(): StorageProvider
1483
1438
  ```
1484
1439
 
1485
- - `url` — The request endpoint URL.
1486
- - `config` — Optional request configuration such as headers or body data.
1487
-
1488
- **Returns:** A subscribable HTTP store for the PATCH request with execute and reset methods.
1440
+ **Returns:** The storage provider instance.
1489
1441
 
1490
- #### `createPlatformStores()`
1442
+ #### `getLoggerProvider()`
1491
1443
 
1492
- Create platform stores from the module-level platform info.
1444
+ Gets the logger provider from Svelte context.
1493
1445
 
1494
- Platform information is static (no reactive subscription needed),
1495
- so this returns plain values rather than Svelte stores.
1446
+ ```typescript
1447
+ function getLoggerProvider(): LoggerProvider
1448
+ ```
1449
+
1450
+ **Returns:** The logger provider instance.
1451
+
1452
+ #### `createAsyncState(initialValue)`
1453
+
1454
+ Creates a writable store with async-capable setState and extendState.
1496
1455
 
1497
1456
  ```typescript
1498
- function createPlatformStores(): {
1499
- platform: Platform
1500
- isNative: boolean
1501
- isMobile: boolean
1502
- isDesktop: boolean
1503
- isWeb: boolean
1504
- isDevelopment: boolean
1505
- isProduction: boolean
1506
- isPlatform: (...platforms: Platform[]) => boolean
1507
- }
1457
+ function createAsyncState(initialValue: T): AsyncStateStore<T>
1508
1458
  ```
1509
1459
 
1510
- **Returns:** Platform information and utility functions
1460
+ - `initialValue` — The initial state value
1511
1461
 
1512
- #### `createPostStore(url, config)`
1462
+ **Returns:** The created instance.
1513
1463
 
1514
- Creates a POST request store.
1464
+ #### `createAuthStores()`
1465
+
1466
+ Create auth stores from the auth client in context.
1515
1467
 
1516
1468
  ```typescript
1517
- function createPostStore(url: string, config?: RequestConfig): HttpStore<T>
1469
+ function createAuthStores(): AuthStores<T, TRegister> & { error: Readable<string | null> }
1518
1470
  ```
1519
1471
 
1520
- - `url` — The request endpoint URL.
1521
- - `config` — Optional request configuration such as headers or body data.
1472
+ **Returns:** Auth stores and actions
1522
1473
 
1523
- **Returns:** A subscribable HTTP store for the POST request with execute and reset methods.
1474
+ #### `createAuthStoresFromClient(client)`
1524
1475
 
1525
- #### `createPromiseStore(asyncFn)`
1476
+ Create auth stores from a specific auth client.
1526
1477
 
1527
- Creates a store that tracks async function state.
1478
+ Use this when you don't want to use context.
1528
1479
 
1529
1480
  ```typescript
1530
- function createPromiseStore(asyncFn: T): PromiseStore<Awaited<ReturnType<T>>>
1481
+ function createAuthStoresFromClient(client: AuthClient<T, TRegister>): AuthStores<T, TRegister>
1531
1482
  ```
1532
1483
 
1533
- - `asyncFn` — The async function to track
1484
+ - `client` — Auth client
1534
1485
 
1535
- **Returns:** Promise store with subscribe, call, cancel, and reset
1486
+ **Returns:** Auth stores and actions
1536
1487
 
1537
- #### `createPushStores()`
1488
+ #### `createCapacitorAppStore(options)`
1538
1489
 
1539
- Create push notification stores from the module-level push provider.
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.
1540
1495
 
1541
1496
  ```typescript
1542
- function createPushStores(): {
1543
- permission: Readable<PermissionStatus | null>
1544
- token: Readable<PushToken | null>
1545
- checkPermission: () => Promise<PermissionStatus>
1546
- requestPermission: () => Promise<PermissionStatus>
1547
- register: (options?: PushRegisterOptions) => Promise<PushToken>
1548
- unregister: () => Promise<void>
1549
- onNotificationReceived: (listener: NotificationReceivedListener) => () => void
1550
- onNotificationAction: (listener: NotificationActionListener) => () => void
1551
- onTokenChange: (listener: TokenChangeListener) => () => void
1552
- setBadge: (count: number) => Promise<void>
1553
- clearBadge: () => Promise<void>
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[]
1554
1532
  }
1555
1533
  ```
1556
1534
 
1557
- **Returns:** Push notification stores and actions
1535
+ **Returns:** Device information and utility functions
1558
1536
 
1559
- #### `createPutStore(url, config)`
1537
+ #### `createFormStores(provider, options)`
1560
1538
 
1561
- Creates a PUT request store.
1539
+ Create form stores from a form provider and options.
1562
1540
 
1563
1541
  ```typescript
1564
- function createPutStore(url: string, config?: RequestConfig): HttpStore<T>
1542
+ function createFormStores(provider: FormProvider, options: FormOptions<T>): FormStores<T>
1565
1543
  ```
1566
1544
 
1567
- - `url` — The request endpoint URL.
1568
- - `config` — Optional request configuration such as headers or body data.
1545
+ - `provider` — Form provider instance
1546
+ - `options` — Form creation options
1569
1547
 
1570
- **Returns:** A subscribable HTTP store for the PUT request with execute and reset methods.
1548
+ **Returns:** Form stores and actions
1571
1549
 
1572
- #### `createRouterStores()`
1550
+ #### `createFieldStore(controller, name)`
1573
1551
 
1574
- Create router stores from the router in context.
1552
+ Create a readable store that tracks a single field's state.
1575
1553
 
1576
1554
  ```typescript
1577
- function createRouterStores(): RouterStores
1555
+ function createFieldStore(controller: FormController<T>, name: K): Readable<FieldState<T[K]>>
1578
1556
  ```
1579
1557
 
1580
- **Returns:** Router stores and actions
1558
+ - `controller` — Form controller
1559
+ - `name` — Field name to track
1581
1560
 
1582
- #### `createRouterStoresFromRouter(router)`
1561
+ **Returns:** Readable store of the field state
1583
1562
 
1584
- Create router stores from a specific router.
1563
+ #### `createWatchStore(controller, name)`
1564
+
1565
+ Create a readable store that tracks a single field's value.
1585
1566
 
1586
1567
  ```typescript
1587
- function createRouterStoresFromRouter(router: Router): RouterStores
1568
+ function createWatchStore(controller: FormController<T>, name: K): Readable<T[K]>
1588
1569
  ```
1589
1570
 
1590
- - `router` — Router instance
1571
+ - `controller` — Form controller
1572
+ - `name` — Field name to watch
1591
1573
 
1592
- **Returns:** Router stores and actions
1574
+ **Returns:** Readable store of the field value
1593
1575
 
1594
- #### `createSignupStore()`
1576
+ #### `createHttpStore(method, url, config)`
1595
1577
 
1596
- Creates a signup store with async state tracking.
1578
+ Create an HTTP request store.
1597
1579
 
1598
1580
  ```typescript
1599
- function createSignupStore(): SignupStore<T>
1581
+ function createHttpStore(
1582
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
1583
+ url: string,
1584
+ config?: RequestConfig,
1585
+ ): HttpStore<T>
1600
1586
  ```
1601
1587
 
1602
- **Returns:** Signup promise store
1588
+ - `method` — HTTP method
1589
+ - `url` — Request URL
1590
+ - `config` — Request configuration
1603
1591
 
1604
- #### `createStorageHelpers()`
1592
+ **Returns:** Store with state and actions
1605
1593
 
1606
- Create storage helper functions from context.
1594
+ #### `createGetStore(url, config)`
1595
+
1596
+ Creates a GET request store.
1607
1597
 
1608
1598
  ```typescript
1609
- function createStorageHelpers(): StorageHelpers
1599
+ function createGetStore(url: string, config?: RequestConfig): HttpStore<T>
1610
1600
  ```
1611
1601
 
1612
- **Returns:** Storage functions
1602
+ - `url` — The request endpoint URL.
1603
+ - `config` — Optional request configuration such as headers or params.
1613
1604
 
1614
- #### `createStorageStore(key, defaultValue)`
1605
+ **Returns:** A subscribable HTTP store for the GET request with execute and reset methods.
1615
1606
 
1616
- Create a storage value store.
1607
+ #### `createPostStore(url, config)`
1608
+
1609
+ Creates a POST request store.
1617
1610
 
1618
1611
  ```typescript
1619
- function createStorageStore(key: string, defaultValue?: T): StorageStore<T>
1612
+ function createPostStore(url: string, config?: RequestConfig): HttpStore<T>
1620
1613
  ```
1621
1614
 
1622
- - `key` — Storage key
1623
- - `defaultValue` — Default value if not found
1615
+ - `url` — The request endpoint URL.
1616
+ - `config` — Optional request configuration such as headers or body data.
1624
1617
 
1625
- **Returns:** Store with value and actions
1618
+ **Returns:** A subscribable HTTP store for the POST request with execute and reset methods.
1626
1619
 
1627
- #### `createStorageStoreFromProvider(storage, key, defaultValue)`
1620
+ #### `createPutStore(url, config)`
1628
1621
 
1629
- Create storage store from a specific provider.
1622
+ Creates a PUT request store.
1630
1623
 
1631
1624
  ```typescript
1632
- function createStorageStoreFromProvider(
1633
- storage: StorageProvider,
1634
- key: string,
1635
- defaultValue?: T,
1636
- ): StorageStore<T>
1625
+ function createPutStore(url: string, config?: RequestConfig): HttpStore<T>
1637
1626
  ```
1638
1627
 
1639
- - `storage` — Storage provider
1640
- - `key` — Storage key
1641
- - `defaultValue` — Default value
1628
+ - `url` — The request endpoint URL.
1629
+ - `config` — Optional request configuration such as headers or body data.
1642
1630
 
1643
- **Returns:** Store with value and actions
1631
+ **Returns:** A subscribable HTTP store for the PUT request with execute and reset methods.
1644
1632
 
1645
- #### `createStoreAction(store, action)`
1633
+ #### `createPatchStore(url, config)`
1646
1634
 
1647
- Create a bound action for a store.
1635
+ Creates a PATCH request store.
1648
1636
 
1649
1637
  ```typescript
1650
- function createStoreAction(
1651
- store: MoleculeStore<T>,
1652
- action: (
1653
- setState: MoleculeStore<T>['setState'],
1654
- getState: MoleculeStore<T>['getState'],
1655
- ) => (...args: Args) => R,
1656
- ): (...args: Args) => R
1638
+ function createPatchStore(url: string, config?: RequestConfig): HttpStore<T>
1657
1639
  ```
1658
1640
 
1659
- - `store` — The store
1660
- - `action` — Action creator function
1641
+ - `url` — The request endpoint URL.
1642
+ - `config` — Optional request configuration such as headers or body data.
1661
1643
 
1662
- **Returns:** Bound action
1644
+ **Returns:** A subscribable HTTP store for the PATCH request with execute and reset methods.
1663
1645
 
1664
- #### `createStoreReadable(store)`
1646
+ #### `createDeleteStore(url, config)`
1665
1647
 
1666
- Create a readable Svelte store from a molecule store.
1648
+ Creates a DELETE request store.
1667
1649
 
1668
1650
  ```typescript
1669
- function createStoreReadable(store: MoleculeStore<T>): Readable<T>
1651
+ function createDeleteStore(url: string, config?: RequestConfig): HttpStore<T>
1670
1652
  ```
1671
1653
 
1672
- - `store` — The molecule store
1654
+ - `url` — The request endpoint URL.
1655
+ - `config` — Optional request configuration such as headers or params.
1673
1656
 
1674
- **Returns:** Readable Svelte store
1657
+ **Returns:** A subscribable HTTP store for the DELETE request with execute and reset methods.
1675
1658
 
1676
- #### `createStoreSelector(store, selector)`
1659
+ #### `createHttpStoresFromClient(client)`
1677
1660
 
1678
- Create a derived Svelte store with a selector.
1661
+ Creates HTTP store factory methods bound to a specific client instance.
1679
1662
 
1680
1663
  ```typescript
1681
- function createStoreSelector(store: MoleculeStore<T>, selector: (state: T) => S): Readable<S>
1664
+ function createHttpStoresFromClient(client: HttpClient): HttpStoreFactory
1682
1665
  ```
1683
1666
 
1684
- - `store` — The molecule store
1685
- - `selector` — Selector function
1667
+ - `client` — The HTTP client to use for all created stores.
1686
1668
 
1687
- **Returns:** Derived Svelte store
1669
+ **Returns:** An object with get, post, put, patch, and delete factory methods.
1688
1670
 
1689
- #### `createThemeColorsStore(theme)`
1671
+ #### `createI18nStores()`
1690
1672
 
1691
- Create a derived store that returns just the theme colors.
1673
+ Create i18n stores from the i18n provider in context.
1692
1674
 
1693
1675
  ```typescript
1694
- function createThemeColorsStore(theme: Readable<Theme>): Readable<ThemeColors>
1676
+ function createI18nStores(): I18nStores
1695
1677
  ```
1696
1678
 
1697
- - `theme` — A readable theme store (from createThemeStores or createThemeStoresFromProvider)
1679
+ **Returns:** I18n stores and actions
1698
1680
 
1699
- **Returns:** Readable store of theme colors
1681
+ #### `createI18nStoresFromProvider(provider)`
1700
1682
 
1701
- #### `createThemeStores()`
1683
+ Create i18n stores from a specific provider.
1702
1684
 
1703
- 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.
1704
1696
 
1705
1697
  ```typescript
1706
- function createThemeStores(): ThemeStores & { colors: Readable<Theme['colors']> }
1698
+ function getLogger(name?: string): Logger
1707
1699
  ```
1708
1700
 
1709
- **Returns:** Theme stores and actions
1701
+ - `name` — Logger name
1710
1702
 
1711
- #### `createThemeStoresFromProvider(provider)`
1703
+ **Returns:** Logger instance
1712
1704
 
1713
- Create theme stores from a specific theme provider.
1705
+ #### `createLogger(config)`
1706
+
1707
+ Create a logger with custom configuration.
1714
1708
 
1715
1709
  ```typescript
1716
- function createThemeStoresFromProvider(provider: ThemeProvider): ThemeStores
1710
+ function createLogger(config: LoggerConfig): Logger
1717
1711
  ```
1718
1712
 
1719
- - `provider` — Theme provider
1713
+ - `config` — Logger configuration
1720
1714
 
1721
- **Returns:** Theme stores and actions
1715
+ **Returns:** Logger instance
1722
1716
 
1723
- #### `createVersionStores()`
1717
+ #### `getRootLogger()`
1724
1718
 
1725
- Create version stores from the module-level version provider.
1719
+ Get the root logger.
1726
1720
 
1727
1721
  ```typescript
1728
- function createVersionStores(): {
1729
- state: Readable<VersionState>
1730
- isUpdateAvailable: Readable<boolean>
1731
- isChecking: Readable<boolean>
1732
- isServiceWorkerWaiting: Readable<boolean>
1733
- newVersion: Readable<string | undefined>
1734
- checkForUpdates: () => Promise<boolean>
1735
- applyUpdate: (options?: { force?: boolean }) => void
1736
- dismissUpdate: () => void
1737
- startPeriodicChecks: (options?: UpdateCheckOptions) => void
1738
- stopPeriodicChecks: () => void
1739
- }
1722
+ function getRootLogger(): Logger
1740
1723
  ```
1741
1724
 
1742
- **Returns:** Version stores and actions
1725
+ **Returns:** Root logger instance
1743
1726
 
1744
- #### `createWatchStore(controller, name)`
1727
+ #### `getChildLogger(name, context)`
1745
1728
 
1746
- Create a readable store that tracks a single field's value.
1729
+ Create a child logger with additional context.
1747
1730
 
1748
1731
  ```typescript
1749
- function createWatchStore(controller: FormController<T>, name: K): Readable<T[K]>
1732
+ function getChildLogger(name: string, context: Record<string, unknown>): Logger
1750
1733
  ```
1751
1734
 
1752
- - `controller` — Form controller
1753
- - `name` — Field name to watch
1735
+ - `name` — Parent logger name
1736
+ - `context` — Additional context
1754
1737
 
1755
- **Returns:** Readable store of the field value
1738
+ **Returns:** Child logger instance
1756
1739
 
1757
- #### `getAuthClient()`
1740
+ #### `createLoggerHelpers()`
1758
1741
 
1759
- Gets the auth client from Svelte context.
1742
+ Create logger helpers from context.
1760
1743
 
1761
1744
  ```typescript
1762
- function getAuthClient(): AuthClient<T>
1745
+ function createLoggerHelpers(): LoggerHelpers
1763
1746
  ```
1764
1747
 
1765
- **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.
1766
1775
 
1767
- #### `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).
1768
1779
 
1769
- 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`.
1770
1786
 
1771
1787
  ```typescript
1772
- function getChildLogger(name: string, context: Record<string, unknown>): Logger
1788
+ function createOAuthHelpers(options?: OAuthOptions): OAuthHelpers
1773
1789
  ```
1774
1790
 
1775
- - `name` — Parent logger name
1776
- - `context` — Additional context
1791
+ - `options` — OAuth configuration (base URL, providers, endpoint paths, callbacks, auth client).
1777
1792
 
1778
- **Returns:** Child logger instance
1793
+ **Returns:** An object containing a readable providers store, URL builder, redirect function, and callback handler.
1779
1794
 
1780
- #### `getHttpClient()`
1795
+ #### `createPasswordResetStores()`
1781
1796
 
1782
- Gets the HTTP client from Svelte context.
1797
+ Creates password reset stores with async state tracking.
1783
1798
 
1784
1799
  ```typescript
1785
- function getHttpClient(): HttpClient
1800
+ function createPasswordResetStores(): PasswordResetStores
1786
1801
  ```
1787
1802
 
1788
- **Returns:** The HTTP client instance.
1803
+ **Returns:** Password reset stores for request and confirm steps
1789
1804
 
1790
- #### `getI18nProvider()`
1805
+ #### `createPlatformStores()`
1791
1806
 
1792
- 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.
1793
1811
 
1794
1812
  ```typescript
1795
- 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
+ }
1796
1823
  ```
1797
1824
 
1798
- **Returns:** The i18n provider instance.
1825
+ **Returns:** Platform information and utility functions
1799
1826
 
1800
- #### `getLogger(name)`
1827
+ #### `createPromiseStore(asyncFn)`
1801
1828
 
1802
- Get a logger instance.
1829
+ Creates a store that tracks async function state.
1803
1830
 
1804
1831
  ```typescript
1805
- function getLogger(name?: string): Logger
1832
+ function createPromiseStore(asyncFn: T): PromiseStore<Awaited<ReturnType<T>>>
1806
1833
  ```
1807
1834
 
1808
- - `name` — Logger name
1835
+ - `asyncFn` — The async function to track
1809
1836
 
1810
- **Returns:** Logger instance
1837
+ **Returns:** Promise store with subscribe, call, cancel, and reset
1811
1838
 
1812
- #### `getLoggerProvider()`
1839
+ #### `createPushStores()`
1813
1840
 
1814
- Gets the logger provider from Svelte context.
1841
+ Create push notification stores from the module-level push provider.
1815
1842
 
1816
1843
  ```typescript
1817
- 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
+ }
1818
1857
  ```
1819
1858
 
1820
- **Returns:** The logger provider instance.
1859
+ **Returns:** Push notification stores and actions
1821
1860
 
1822
- #### `getRootLogger()`
1861
+ #### `createRouterStores()`
1823
1862
 
1824
- Get the root logger.
1863
+ Create router stores from the router in context.
1825
1864
 
1826
1865
  ```typescript
1827
- function getRootLogger(): Logger
1866
+ function createRouterStores(): RouterStores
1828
1867
  ```
1829
1868
 
1830
- **Returns:** Root logger instance
1869
+ **Returns:** Router stores and actions
1831
1870
 
1832
- #### `getRouter()`
1871
+ #### `createIsActiveStore(location, router, path, exact)`
1833
1872
 
1834
- Gets the router from Svelte context.
1873
+ Create a derived store that checks if a path is active.
1835
1874
 
1836
1875
  ```typescript
1837
- function getRouter(): Router
1876
+ function createIsActiveStore(
1877
+ location: Readable<RouteLocation>,
1878
+ router: Router,
1879
+ path: string,
1880
+ exact?: boolean,
1881
+ ): Readable<boolean>
1838
1882
  ```
1839
1883
 
1840
- **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)
1841
1888
 
1842
- #### `getSetStore(store)`
1889
+ **Returns:** Readable store of whether the path is active
1843
1890
 
1844
- Get the setState function from a molecule store.
1891
+ #### `createRouterStoresFromRouter(router)`
1892
+
1893
+ Create router stores from a specific router.
1845
1894
 
1846
1895
  ```typescript
1847
- function getSetStore(
1848
- store: MoleculeStore<T>,
1849
- ): (partial: Partial<T> | ((state: T) => Partial<T>)) => void
1896
+ function createRouterStoresFromRouter(router: Router): RouterStores
1850
1897
  ```
1851
1898
 
1852
- - `store` — The molecule store
1899
+ - `router` — Router instance
1853
1900
 
1854
- **Returns:** setState function
1901
+ **Returns:** Router stores and actions
1855
1902
 
1856
- #### `getStateProvider()`
1903
+ #### `createSignupStore()`
1857
1904
 
1858
- Gets the state provider from Svelte context.
1905
+ Creates a signup store with async state tracking.
1859
1906
 
1860
1907
  ```typescript
1861
- function getStateProvider(): StateProvider
1908
+ function createSignupStore(): SignupStore<T>
1862
1909
  ```
1863
1910
 
1864
- **Returns:** The state provider instance.
1911
+ **Returns:** Signup promise store
1865
1912
 
1866
- #### `getStorageProvider()`
1913
+ #### `createStoreReadable(store)`
1867
1914
 
1868
- Gets the storage provider from Svelte context.
1915
+ Create a readable Svelte store from a molecule store.
1869
1916
 
1870
1917
  ```typescript
1871
- function getStorageProvider(): StorageProvider
1918
+ function createStoreReadable(store: MoleculeStore<T>): Readable<T>
1872
1919
  ```
1873
1920
 
1874
- **Returns:** The storage provider instance.
1921
+ - `store` — The molecule store
1875
1922
 
1876
- #### `getThemeProvider()`
1923
+ **Returns:** Readable Svelte store
1877
1924
 
1878
- Gets the theme provider from Svelte context.
1925
+ #### `createStoreSelector(store, selector)`
1926
+
1927
+ Create a derived Svelte store with a selector.
1879
1928
 
1880
1929
  ```typescript
1881
- function getThemeProvider(): ThemeProvider
1930
+ function createStoreSelector(store: MoleculeStore<T>, selector: (state: T) => S): Readable<S>
1882
1931
  ```
1883
1932
 
1884
- **Returns:** The theme provider instance.
1933
+ - `store` — The molecule store
1934
+ - `selector` — Selector function
1885
1935
 
1886
- #### `setAuthContext(client)`
1936
+ **Returns:** Derived Svelte store
1887
1937
 
1888
- Sets the auth context.
1938
+ #### `getSetStore(store)`
1939
+
1940
+ Get the setState function from a molecule store.
1889
1941
 
1890
1942
  ```typescript
1891
- function setAuthContext(client: AuthClient<T>): void
1943
+ function getSetStore(
1944
+ store: MoleculeStore<T>,
1945
+ ): (partial: Partial<T> | ((state: T) => Partial<T>)) => void
1892
1946
  ```
1893
1947
 
1894
- - `client` — The auth client to store in Svelte context.
1948
+ - `store` — The molecule store
1895
1949
 
1896
- #### `setHttpContext(client)`
1950
+ **Returns:** setState function
1897
1951
 
1898
- Sets the HTTP context.
1952
+ #### `createStoreAction(store, action)`
1953
+
1954
+ Create a bound action for a store.
1899
1955
 
1900
1956
  ```typescript
1901
- 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
1902
1964
  ```
1903
1965
 
1904
- - `client` — The HTTP client to store in Svelte context.
1966
+ - `store` — The store
1967
+ - `action` — Action creator function
1905
1968
 
1906
- #### `setI18nContext(provider)`
1969
+ **Returns:** Bound action
1907
1970
 
1908
- Sets the i18n context.
1971
+ #### `createStorageStore(key, defaultValue)`
1972
+
1973
+ Create a storage value store.
1909
1974
 
1910
1975
  ```typescript
1911
- function setI18nContext(provider: I18nProvider): void
1976
+ function createStorageStore(key: string, defaultValue?: T): StorageStore<T>
1912
1977
  ```
1913
1978
 
1914
- - `provider` — The i18n provider to store in Svelte context.
1979
+ - `key` — Storage key
1980
+ - `defaultValue` — Default value if not found
1915
1981
 
1916
- #### `setLoggerContext(provider)`
1982
+ **Returns:** Store with value and actions
1917
1983
 
1918
- Sets the logger context.
1984
+ #### `createStorageHelpers()`
1985
+
1986
+ Create storage helper functions from context.
1919
1987
 
1920
1988
  ```typescript
1921
- function setLoggerContext(provider: LoggerProvider): void
1989
+ function createStorageHelpers(): StorageHelpers
1922
1990
  ```
1923
1991
 
1924
- - `provider` — The logger provider to store in Svelte context.
1925
-
1926
- #### `setMoleculeContext(config)`
1992
+ **Returns:** Storage functions
1927
1993
 
1928
- Set all molecule providers in Svelte context.
1994
+ #### `createStorageStoreFromProvider(storage, key, defaultValue)`
1929
1995
 
1930
- Call this in your root layout/component.
1996
+ Create storage store from a specific provider.
1931
1997
 
1932
1998
  ```typescript
1933
- function setMoleculeContext(config: MoleculeConfig): void
1999
+ function createStorageStoreFromProvider(
2000
+ storage: StorageProvider,
2001
+ key: string,
2002
+ defaultValue?: T,
2003
+ ): StorageStore<T>
1934
2004
  ```
1935
2005
 
1936
- - `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
1937
2009
 
1938
- #### `setRouterContext(router)`
2010
+ **Returns:** Store with value and actions
1939
2011
 
1940
- Sets the router context.
2012
+ #### `createThemeStores()`
2013
+
2014
+ Create theme stores from the theme provider in context.
1941
2015
 
1942
2016
  ```typescript
1943
- function setRouterContext(router: Router): void
2017
+ function createThemeStores(): ThemeStores & { colors: Readable<Theme['colors']> }
1944
2018
  ```
1945
2019
 
1946
- - `router` — The router instance to store in Svelte context.
2020
+ **Returns:** Theme stores and actions
1947
2021
 
1948
- #### `setStateContext(provider)`
2022
+ #### `createThemeColorsStore(theme)`
1949
2023
 
1950
- Sets the state context.
2024
+ Create a derived store that returns just the theme colors.
1951
2025
 
1952
2026
  ```typescript
1953
- function setStateContext(provider: StateProvider): void
2027
+ function createThemeColorsStore(theme: Readable<Theme>): Readable<ThemeColors>
1954
2028
  ```
1955
2029
 
1956
- - `provider` — The state provider to store in Svelte context.
2030
+ - `theme` — A readable theme store (from createThemeStores or createThemeStoresFromProvider)
1957
2031
 
1958
- #### `setStorageContext(provider)`
2032
+ **Returns:** Readable store of theme colors
1959
2033
 
1960
- Sets the storage context.
2034
+ #### `createThemeStoresFromProvider(provider)`
2035
+
2036
+ Create theme stores from a specific theme provider.
1961
2037
 
1962
2038
  ```typescript
1963
- function setStorageContext(provider: StorageProvider): void
2039
+ function createThemeStoresFromProvider(provider: ThemeProvider): ThemeStores
1964
2040
  ```
1965
2041
 
1966
- - `provider` — The storage provider to store in Svelte context.
2042
+ - `provider` — Theme provider
1967
2043
 
1968
- #### `setThemeContext(provider)`
2044
+ **Returns:** Theme stores and actions
1969
2045
 
1970
- Sets the theme context.
2046
+ #### `createVersionStores()`
2047
+
2048
+ Create version stores from the module-level version provider.
1971
2049
 
1972
2050
  ```typescript
1973
- 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
+ }
1974
2063
  ```
1975
2064
 
1976
- - `provider` — The theme provider to store in Svelte context.
2065
+ **Returns:** Version stores and actions
1977
2066
 
1978
2067
  ## Injection Notes
1979
2068