@molecule/app-svelte 1.0.2 → 1.0.4

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-23T21:29:58.335Z
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,180 @@ 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
+ * Optional ownership marker for the current session. Compare values only within
170
+ * this client: replacing or ending a session changes it, including re-adopting
171
+ * the same token and user. Profile updates and same-session refreshes keep it.
172
+ * Consumers can use it to discard stale async work without treating editable
173
+ * user fields as an immutable account identifier. Providers without this
174
+ * capability require the consumer's own stable identity check.
175
+ */
176
+ getSessionRevision?(): number;
177
+ /**
178
+ * Updates the cached user object (state + persistent storage) without
179
+ * hitting the network. Intended for local refreshes after a per-app
180
+ * mutation (e.g., the user just PATCHed their own profile and the
181
+ * server returned the canonical row). Does NOT change tokens.
182
+ *
183
+ * This does not sign the client in: `authenticated` and `status` are
184
+ * unchanged, so an anonymous client stays anonymous. Use
185
+ * {@link login} / {@link register} for a credential exchange, or
186
+ * {@link setSession} when the token was issued outside the client.
187
+ */
188
+ setUser(user: T | null): void;
189
+ /**
190
+ * Gets the current access token.
191
+ */
192
+ getAccessToken(): string | null;
193
+ /**
194
+ * Stores the access token in the configured token storage adapter (in a
195
+ * browser, Web Storage; `'memory'` where no browser store exists). Use this
196
+ * to seed the token after an out-of-band exchange (e.g. the OAuth
197
+ * code→token redirect) instead of writing to `localStorage` directly,
198
+ * which would violate the storage contract and make a stored bearer token
199
+ * JS-readable (XSS-exfiltratable). Pass `null` to clear it.
200
+ *
201
+ * This changes token storage only; it does not sign the client in
202
+ * (`authenticated` and `status` are unchanged). Use {@link login} /
203
+ * {@link register} for a credential exchange, or call {@link setSession}
204
+ * with the token and the user to establish an already-issued session.
205
+ */
206
+ setAccessToken(token: string | null): void;
207
+ /**
208
+ * Adopts a session an out-of-band exchange already established: stores the
209
+ * access token (and the refresh token when given), caches the user, and
210
+ * sets the COMPLETE state — `initialized`, `authenticated`, `status:
211
+ * 'authenticated'`, no error — in one update, with one subscriber
212
+ * notification. Every hook reading the shared client sees the user as
213
+ * signed in immediately.
214
+ *
215
+ * This is the way to seed an OAuth/custom sign-in. Calling
216
+ * {@link setAccessToken} and {@link setUser} instead does NOT sign the
217
+ * client in.
218
+ */
219
+ setSession(session: AuthSessionSeed<T>): void;
220
+ /**
221
+ * Gets the refresh token.
222
+ */
223
+ getRefreshToken(): string | null;
224
+ /**
225
+ * Logs in with credentials.
226
+ */
227
+ login(credentials: LoginCredentials): Promise<AuthResult<T>>;
228
+ /**
229
+ * Logs out the current user.
230
+ */
231
+ logout(): Promise<void>;
232
+ /**
233
+ * Registers a new user. Accepts the base fields plus the app's own fields
234
+ * (`TRegister`) at the top level — see {@link RegisterData}.
235
+ */
236
+ register(data: RegisterData<TRegister>): Promise<AuthResult<T>>;
237
+ /**
238
+ * Refreshes the access token.
239
+ */
240
+ refresh(): Promise<AuthResult<T>>;
241
+ /**
242
+ * Requests a password reset.
243
+ */
244
+ requestPasswordReset(data: PasswordResetRequest): Promise<void>;
245
+ /**
246
+ * Confirms a password reset.
247
+ */
248
+ confirmPasswordReset(data: PasswordResetConfirm): Promise<void>;
249
+ /**
250
+ * Updates the current user's profile.
251
+ * Returns the saved response. If the session is explicitly replaced or ended
252
+ * while the request is pending, that response does not replace the current
253
+ * session's user or persisted cache.
254
+ */
255
+ updateProfile(data: Partial<T>): Promise<T>;
256
+ /**
257
+ * Changes the current user's password.
258
+ */
259
+ changePassword(oldPassword: string, newPassword: string): Promise<void>;
260
+ /**
261
+ * Initializes auth state (e.g., from stored tokens).
262
+ *
263
+ * LAZY and IDEMPOTENT: the first read of the state ({@link getState},
264
+ * {@link subscribe}, `useAuth()`) starts this same restore when nobody has called
265
+ * `initialize()`, and every later call shares the one promise instead of sending a
266
+ * second request. An app that keeps the template's explicit call behaves exactly as
267
+ * before; an app that loses that line still restores its session.
268
+ *
269
+ * With a stored token AND a stored user it marks the session `'authenticated'`
270
+ * SYNCHRONOUSLY — before its first `await` — so the first render is the
271
+ * signed-in UI and no page waits on a verification round trip. Any check
272
+ * (a refresh, the cookie-restore probe) settles behind that render, and only an
273
+ * explicit 401/403 ends the session; a network/5xx/404 failure keeps it and
274
+ * reports `'unavailable'`. With no stored user the client stays `'loading'`
275
+ * until the cookie restore decides.
276
+ *
277
+ * Do not put this call (or a `/me` request of your own) in front of the first
278
+ * render, and do not render a loading screen over a session it just restored:
279
+ * `whenRestored()` already resolves as soon as the restore has settled, and the
280
+ * HTTP gate built on it holds requests for exactly that window.
281
+ */
282
+ initialize(): Promise<void>;
283
+ /**
284
+ * Re-checks a restored session against the server, in the background — the
285
+ * boot-time validation an app with a stored token needs when a revoked or
286
+ * expired token must sign the user out. Call it AFTER the first render
287
+ * (`initialize()` restores synchronously from storage; this costs one request).
288
+ *
289
+ * - The server confirms the user: the session is refreshed and {@link AuthState.status}
290
+ * stays `'authenticated'`.
291
+ * - The server answers 401 or 403: the token is dead — the stored session is
292
+ * cleared and the status becomes `'unauthenticated'`.
293
+ * - The server cannot confirm the session — a network failure, a 5xx, or a 404
294
+ * from a misconfigured {@link AuthClientConfig.currentUserEndpoint}: the
295
+ * session (token AND user) is KEPT and the status becomes `'unavailable'`, so
296
+ * the app can retry instead of signing the user out over a bad connection or a
297
+ * route that does not exist. The 404 error names `currentUserEndpoint`.
298
+ *
299
+ * Do not hand-write this beside the client: a parallel token/user store for a
300
+ * "validating"/"unavailable" flag is the race this method removes.
301
+ *
302
+ * Optional: a provider with no restorable session has nothing to validate.
303
+ */
304
+ validateSession?(): Promise<void>;
305
+ /**
306
+ * Resolves when the session restore started by `initialize()` has settled — the point
307
+ * after which the client knows whether this visitor is signed in.
308
+ *
309
+ * Resolves IMMEDIATELY when no restore is in flight: before `initialize()` is ever
310
+ * called, and after it has finished. A restore that failed resolves too (it settled the
311
+ * question), so an HTTP client can await this before every request without risking one
312
+ // … truncated — the full declaration is in node_modules/@molecule/app-svelte/dist
313
+ ```
314
+
217
315
  #### `FormController`
218
316
 
219
317
  Form controller interface.
@@ -293,7 +391,13 @@ interface FormController<T extends Record<string, unknown> = Record<string, unkn
293
391
  */
294
392
  validate(): Promise<boolean>
295
393
  /**
296
- * Resets the form to initial values.
394
+ * Resets the form and clears errors, touched fields and submission state.
395
+ *
396
+ * With no argument it restores the current baseline — the initial
397
+ * `defaultValues`, or the values a previous `reset(values)` established.
398
+ * Passing `values` merges them over the current baseline and makes the
399
+ * result the new baseline, so a form reset to freshly loaded or saved data
400
+ * reads clean (`isDirty === false`).
297
401
  */
298
402
  reset(values?: Partial<T>): void
299
403
  /**
@@ -325,7 +429,8 @@ Form creation options.
325
429
  ```typescript
326
430
  interface FormOptions<T extends Record<string, unknown>> {
327
431
  /**
328
- * Default values.
432
+ * Default values, captured as the form's clean baseline when the controller
433
+ * is created. Mutating this object afterwards does not change the baseline.
329
434
  */
330
435
  defaultValues?: Partial<T>
331
436
  /**
@@ -366,7 +471,8 @@ interface HttpClient {
366
471
  */
367
472
  defaultHeaders: Record<string, string>
368
473
  /**
369
- * Makes a generic HTTP request.
474
+ * Makes a generic HTTP request. `data` is a field of THIS config object — the same body
475
+ * `post(url, data, config)` takes as its second argument.
370
476
  */
371
477
  request<T = unknown>(config: FullRequestConfig): Promise<HttpResponse<T>>
372
478
  /**
@@ -374,15 +480,19 @@ interface HttpClient {
374
480
  */
375
481
  get<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
376
482
  /**
377
- * Makes a POST request.
483
+ * Makes a POST request. `data` is the request BODY, not a config object: the wire body is
484
+ * `data` itself, so `post(url, { data: body })` sends `{"data":body}` — pass `body` directly.
485
+ * A config (headers, params) is the THIRD argument.
378
486
  */
379
487
  post<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
380
488
  /**
381
- * Makes a PUT request.
489
+ * Makes a PUT request. `data` is the request BODY (second argument) — never `{ data: body }`,
490
+ * which sends `{"data":body}`; a config is the THIRD argument.
382
491
  */
383
492
  put<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
384
493
  /**
385
- * Makes a PATCH request.
494
+ * Makes a PATCH request. `data` is the request BODY (second argument) — never `{ data: body }`,
495
+ * which sends `{"data":body}`; a config is the THIRD argument.
386
496
  */
387
497
  patch<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
388
498
  /**
@@ -421,18 +531,6 @@ interface HttpClient {
421
531
  }
422
532
  ```
423
533
 
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
534
  #### `I18nProvider`
437
535
 
438
536
  i18n provider interface.
@@ -691,149 +789,6 @@ interface LoggerProvider {
691
789
  }
692
790
  ```
693
791
 
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
792
  #### `RouteLocation`
838
793
 
839
794
  Current URL decomposed into pathname, search string, hash, navigation state, and unique key.
@@ -968,18 +923,67 @@ interface Router {
968
923
  }
969
924
  ```
970
925
 
971
- #### `StateProvider`
926
+ #### `StoreConfig`
972
927
 
973
- State provider interface that all state management bond packages
974
- must implement. Provides the store creation factory.
928
+ Configuration for creating a store (initial state, optional name, and middleware chain).
975
929
 
976
930
  ```typescript
977
- interface StateProvider {
931
+ interface StoreConfig<T> {
978
932
  /**
979
- * Creates a new store.
933
+ * Initial state value.
980
934
  */
981
- createStore<T>(config: StoreConfig<T>): Store<T>
982
- }
935
+ initialState: T
936
+ /**
937
+ * Optional name for debugging.
938
+ */
939
+ name?: string
940
+ /**
941
+ * Optional middleware functions.
942
+ */
943
+ middleware?: StoreMiddleware<T>[]
944
+ }
945
+ ```
946
+
947
+ #### `MoleculeStore`
948
+
949
+ Reactive state container with getState, setState, subscribe, and destroy.
950
+
951
+ All state management providers must implement this interface.
952
+
953
+ ```typescript
954
+ interface Store<T> {
955
+ /**
956
+ * Gets the current state.
957
+ */
958
+ getState(): T
959
+ /**
960
+ * Sets the state (partial or via updater function).
961
+ */
962
+ setState(partial: Partial<T> | ((state: T) => Partial<T>)): void
963
+ /**
964
+ * Subscribes to state changes.
965
+ * Returns an unsubscribe function.
966
+ */
967
+ subscribe(listener: StateListener<T>): () => void
968
+ /**
969
+ * Destroys the store and cleans up subscriptions.
970
+ */
971
+ destroy(): void
972
+ }
973
+ ```
974
+
975
+ #### `StateProvider`
976
+
977
+ State provider interface that all state management bond packages
978
+ must implement. Provides the store creation factory.
979
+
980
+ ```typescript
981
+ interface StateProvider {
982
+ /**
983
+ * Creates a new store.
984
+ */
985
+ createStore<T>(config: StoreConfig<T>): Store<T>
986
+ }
983
987
  ```
984
988
 
985
989
  #### `StorageProvider`
@@ -1025,58 +1029,6 @@ interface StorageProvider {
1025
1029
  }
1026
1030
  ```
1027
1031
 
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
1032
  #### `ThemeProvider`
1081
1033
 
1082
1034
  Manages theme state including the active theme, mode toggling,
@@ -1123,866 +1075,1003 @@ interface ThemeProvider {
1123
1075
  }
1124
1076
  ```
1125
1077
 
1126
- #### `Writable`
1078
+ #### `Theme`
1127
1079
 
1128
- Writable interface for both updating and subscribing.
1080
+ Complete theme definition.
1129
1081
 
1130
1082
  ```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
1083
+ interface Theme {
1084
+ name: string
1085
+ mode: 'light' | 'dark'
1086
+ colors: ThemeColors
1087
+ breakpoints: ThemeBreakpoints
1088
+ spacing: ThemeSpacing
1089
+ typography: ThemeTypography
1090
+ borderRadius: ThemeBorderRadius
1091
+ shadows: ThemeShadows
1092
+ transitions: ThemeTransitions
1093
+ zIndex: ThemeZIndex
1143
1094
  }
1144
1095
  ```
1145
1096
 
1146
- ### Types
1147
-
1148
- #### `CapacitorAppStore`
1097
+ #### `AsyncStateStore`
1149
1098
 
1150
- Return type for the Capacitor app store.
1099
+ Async state store.
1151
1100
 
1152
1101
  ```typescript
1153
- type CapacitorAppStore = Readable<CapacitorAppState> & {
1154
- initialize: () => Promise<void>
1102
+ interface AsyncStateStore<T> extends Writable<T> {
1103
+ setState: (value: T | ((prev: T) => T) | Promise<T | ((prev: T) => T)>) => void
1104
+ extendState: (
1105
+ partial:
1106
+ Partial<T> | ((prev: T) => Partial<T>) | Promise<Partial<T> | ((prev: T) => Partial<T>)>,
1107
+ ) => void
1155
1108
  }
1156
1109
  ```
1157
1110
 
1158
- #### `ChangePasswordStore`
1111
+ #### `OAuthOptions`
1159
1112
 
1160
- Change password store type.
1113
+ OAuth configuration options.
1161
1114
 
1162
1115
  ```typescript
1163
- type ChangePasswordStore = PromiseStore<void>
1116
+ interface OAuthOptions {
1117
+ /** Base URL for the API server (e.g. `https://api.example.com`). */
1118
+ baseURL?: string
1119
+ /** List of supported OAuth provider names (e.g. `['google', 'github']`). */
1120
+ oauthProviders?: string[]
1121
+ /** Path prefix for OAuth initiation routes. Defaults to `/oauth`. */
1122
+ oauthEndpoint?: string
1123
+ /** Path for the OAuth login POST endpoint. Defaults to `/users/log-in/oauth`. */
1124
+ loginEndpoint?: string
1125
+ /** Callback fired after a successful OAuth login. */
1126
+ onSuccess?: () => void
1127
+ /** Callback fired with an error message when the OAuth login fails. */
1128
+ onError?: (error: string) => void
1129
+ /**
1130
+ * Explicit auth client used to establish the session after the callback
1131
+ * exchange. Defaults to the client in Svelte context (only resolvable when
1132
+ * called during component initialization) — pass one explicitly for
1133
+ * callers/tests outside a component/context.
1134
+ */
1135
+ authClient?: AuthClient<unknown>
1136
+ }
1164
1137
  ```
1165
1138
 
1166
- #### `LoginStore`
1139
+ #### `OAuthHelpers`
1167
1140
 
1168
- Login store type.
1141
+ OAuth helpers returned by {@link createOAuthHelpers}.
1169
1142
 
1170
1143
  ```typescript
1171
- type LoginStore<T = unknown> = PromiseStore<AuthResult<T>>
1144
+ interface OAuthHelpers {
1145
+ /** Readable store of available OAuth provider names. */
1146
+ providers: Readable<string[]>
1147
+ /** Builds the OAuth initiation URL for a provider. */
1148
+ getOAuthUrl: (provider: string) => string
1149
+ /** Full-page redirect to the provider's OAuth initiation endpoint. */
1150
+ redirect: (provider: string) => void
1151
+ /**
1152
+ * Handles an OAuth callback: when the current URL carries a `code` param and
1153
+ * a provider was stashed by {@link redirect}, exchanges the code for a
1154
+ * session. A guarded no-op otherwise. Runs automatically when
1155
+ * {@link createOAuthHelpers} is called in a browser; exposed for manual
1156
+ * invocation (e.g. tests or custom callback screens).
1157
+ */
1158
+ handleCallback: () => Promise<void>
1159
+ }
1172
1160
  ```
1173
1161
 
1174
- #### `QueryParams`
1162
+ #### `PasswordResetStores`
1175
1163
 
1176
- URL query string parameter map (single values or arrays for repeated keys).
1164
+ Password reset stores.
1177
1165
 
1178
1166
  ```typescript
1179
- type QueryParams = Record<string, string | string[] | undefined>
1167
+ interface PasswordResetStores {
1168
+ request: Readable<PromiseState<void>> & {
1169
+ call: (data: PasswordResetRequest) => Promise<void>
1170
+ cancel: (message?: string) => void
1171
+ reset: () => void
1172
+ }
1173
+ confirm: Readable<PromiseState<void>> & {
1174
+ call: (data: PasswordResetConfirm) => Promise<void>
1175
+ cancel: (message?: string) => void
1176
+ reset: () => void
1177
+ }
1178
+ resetAll: () => void
1179
+ }
1180
1180
  ```
1181
1181
 
1182
- #### `RouteParams`
1182
+ #### `PromiseStore`
1183
1183
 
1184
- URL path parameter key-value map extracted from dynamic route segments (e.g. `{ id: '123' }`).
1184
+ Promise store with action methods.
1185
1185
 
1186
1186
  ```typescript
1187
- type RouteParams = Record<string, string>
1187
+ interface PromiseStore<T> extends Readable<PromiseState<T>> {
1188
+ call: (...args: any[]) => Promise<T>
1189
+ cancel: (message?: string) => void
1190
+ reset: () => void
1191
+ }
1188
1192
  ```
1189
1193
 
1190
- #### `SignupStore`
1194
+ #### `MoleculeConfig`
1191
1195
 
1192
- Signup store type.
1196
+ Configuration for molecule Svelte context.
1193
1197
 
1194
1198
  ```typescript
1195
- type SignupStore<T = unknown> = PromiseStore<AuthResult<T>>
1199
+ interface MoleculeConfig {
1200
+ state?: StateProvider
1201
+ auth?: AuthClient<unknown>
1202
+ theme?: ThemeProvider
1203
+ router?: Router
1204
+ i18n?: I18nProvider
1205
+ http?: HttpClient
1206
+ storage?: StorageProvider
1207
+ logger?: LoggerProvider
1208
+ }
1196
1209
  ```
1197
1210
 
1198
- ### Functions
1199
-
1200
- #### `createAsyncState(initialValue)`
1211
+ #### `HttpState`
1201
1212
 
1202
- Creates a writable store with async-capable setState and extendState.
1213
+ State for async HTTP operations.
1203
1214
 
1204
1215
  ```typescript
1205
- function createAsyncState(initialValue: T): AsyncStateStore<T>
1216
+ interface HttpState<T> {
1217
+ data: T | null
1218
+ loading: boolean
1219
+ error: Error | null
1220
+ }
1206
1221
  ```
1207
1222
 
1208
- - `initialValue` — The initial state value
1209
-
1210
- **Returns:** The created instance.
1211
-
1212
- #### `createAuthStores()`
1223
+ #### `StorageValueState`
1213
1224
 
1214
- Create auth stores from the auth client in context.
1225
+ State for async storage values.
1215
1226
 
1216
1227
  ```typescript
1217
- function createAuthStores(): AuthStores<T> & { error: Readable<string | null> }
1218
- ```
1219
-
1220
- **Returns:** Auth stores and actions
1228
+ interface StorageValueState<T> {
1229
+ value: T | undefined
1230
+ loading: boolean
1231
+ error: Error | null
1232
+ }
1233
+ ```
1221
1234
 
1222
- #### `createAuthStoresFromClient(client)`
1235
+ ### Types
1223
1236
 
1224
- Create auth stores from a specific auth client.
1237
+ #### `RouteParams`
1225
1238
 
1226
- Use this when you don't want to use context.
1239
+ URL path parameter key-value map extracted from dynamic route segments (e.g. `{ id: '123' }`).
1227
1240
 
1228
1241
  ```typescript
1229
- function createAuthStoresFromClient(client: AuthClient<T>): AuthStores<T>
1242
+ type RouteParams = Record<string, string>
1230
1243
  ```
1231
1244
 
1232
- - `client` — Auth client
1245
+ #### `QueryParams`
1233
1246
 
1234
- **Returns:** Auth stores and actions
1247
+ URL query string parameter map (single values or arrays for repeated keys).
1235
1248
 
1236
- #### `createCapacitorAppStore(options)`
1249
+ ```typescript
1250
+ type QueryParams = Record<string, string | string[] | undefined>
1251
+ ```
1237
1252
 
1238
- Create a Svelte store wrapping the Capacitor app coordinator.
1253
+ #### `CapacitorAppStore`
1239
1254
 
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.
1255
+ Return type for the Capacitor app store.
1243
1256
 
1244
1257
  ```typescript
1245
- function createCapacitorAppStore(options?: CapacitorAppOptions): CapacitorAppStore
1258
+ type CapacitorAppStore = Readable<CapacitorAppState> & {
1259
+ initialize: () => Promise<void>
1260
+ }
1246
1261
  ```
1247
1262
 
1248
- - `options` — Capacitor app options
1263
+ #### `ChangePasswordStore`
1249
1264
 
1250
- **Returns:** A readable store of CapacitorAppState with an initialize method
1265
+ Change password store type.
1251
1266
 
1252
- #### `createChangePasswordStore()`
1267
+ ```typescript
1268
+ type ChangePasswordStore = PromiseStore<void>
1269
+ ```
1253
1270
 
1254
- Creates a change password store with async state tracking.
1271
+ #### `LoginStore`
1272
+
1273
+ Login store type.
1255
1274
 
1256
1275
  ```typescript
1257
- function createChangePasswordStore(): ChangePasswordStore
1276
+ type LoginStore<T = unknown> = PromiseStore<AuthResult<T>>
1258
1277
  ```
1259
1278
 
1260
- **Returns:** Change password promise store
1261
-
1262
- #### `createDeleteStore(url, config)`
1279
+ #### `SignupStore`
1263
1280
 
1264
- Creates a DELETE request store.
1281
+ Signup store type.
1265
1282
 
1266
1283
  ```typescript
1267
- function createDeleteStore(url: string, config?: RequestConfig): HttpStore<T>
1284
+ type SignupStore<T = unknown> = PromiseStore<AuthResult<T>>
1268
1285
  ```
1269
1286
 
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.
1287
+ ### Functions
1274
1288
 
1275
- #### `createDeviceStores()`
1289
+ #### `setMoleculeContext(config)`
1276
1290
 
1277
- Create device stores from the module-level device provider.
1291
+ Set all molecule providers in Svelte context.
1278
1292
 
1279
- Device information is static (no reactive subscription needed),
1280
- so this returns plain values rather than Svelte stores.
1293
+ Call this in your root layout/component.
1281
1294
 
1282
1295
  ```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
- }
1296
+ function setMoleculeContext(config: MoleculeConfig): void
1294
1297
  ```
1295
1298
 
1296
- **Returns:** Device information and utility functions
1299
+ - `config` — Provider instances to register (state, auth, theme, router, i18n, http, storage, logger).
1297
1300
 
1298
- #### `createFieldStore(controller, name)`
1301
+ #### `setStateContext(provider)`
1299
1302
 
1300
- Create a readable store that tracks a single field's state.
1303
+ Sets the state context.
1301
1304
 
1302
1305
  ```typescript
1303
- function createFieldStore(controller: FormController<T>, name: K): Readable<FieldState<T[K]>>
1306
+ function setStateContext(provider: StateProvider): void
1304
1307
  ```
1305
1308
 
1306
- - `controller` — Form controller
1307
- - `name` — Field name to track
1308
-
1309
- **Returns:** Readable store of the field state
1309
+ - `provider` — The state provider to store in Svelte context.
1310
1310
 
1311
- #### `createFormStores(provider, options)`
1311
+ #### `setAuthContext(client)`
1312
1312
 
1313
- Create form stores from a form provider and options.
1313
+ Sets the auth context.
1314
1314
 
1315
1315
  ```typescript
1316
- function createFormStores(provider: FormProvider, options: FormOptions<T>): FormStores<T>
1316
+ function setAuthContext(client: AuthClient<T, Record<never, never>>): void
1317
1317
  ```
1318
1318
 
1319
- - `provider` — Form provider instance
1320
- - `options` — Form creation options
1321
-
1322
- **Returns:** Form stores and actions
1319
+ - `client` — The auth client to store in Svelte context.
1323
1320
 
1324
- #### `createGetStore(url, config)`
1321
+ #### `setThemeContext(provider)`
1325
1322
 
1326
- Creates a GET request store.
1323
+ Sets the theme context.
1327
1324
 
1328
1325
  ```typescript
1329
- function createGetStore(url: string, config?: RequestConfig): HttpStore<T>
1326
+ function setThemeContext(provider: ThemeProvider): void
1330
1327
  ```
1331
1328
 
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.
1329
+ - `provider` — The theme provider to store in Svelte context.
1336
1330
 
1337
- #### `createHttpStore(method, url, config)`
1331
+ #### `setRouterContext(router)`
1338
1332
 
1339
- Create an HTTP request store.
1333
+ Sets the router context.
1340
1334
 
1341
1335
  ```typescript
1342
- function createHttpStore(
1343
- method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
1344
- url: string,
1345
- config?: RequestConfig,
1346
- ): HttpStore<T>
1336
+ function setRouterContext(router: Router): void
1347
1337
  ```
1348
1338
 
1349
- - `method` — HTTP method
1350
- - `url` — Request URL
1351
- - `config` — Request configuration
1352
-
1353
- **Returns:** Store with state and actions
1339
+ - `router` — The router instance to store in Svelte context.
1354
1340
 
1355
- #### `createHttpStoresFromClient(client)`
1341
+ #### `setI18nContext(provider)`
1356
1342
 
1357
- Creates HTTP store factory methods bound to a specific client instance.
1343
+ Sets the i18n context.
1358
1344
 
1359
1345
  ```typescript
1360
- function createHttpStoresFromClient(client: HttpClient): HttpStoreFactory
1346
+ function setI18nContext(provider: I18nProvider): void
1361
1347
  ```
1362
1348
 
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.
1349
+ - `provider` — The i18n provider to store in Svelte context.
1366
1350
 
1367
- #### `createI18nStores()`
1351
+ #### `setHttpContext(client)`
1368
1352
 
1369
- Create i18n stores from the i18n provider in context.
1353
+ Sets the HTTP context.
1370
1354
 
1371
1355
  ```typescript
1372
- function createI18nStores(): I18nStores
1356
+ function setHttpContext(client: HttpClient): void
1373
1357
  ```
1374
1358
 
1375
- **Returns:** I18n stores and actions
1359
+ - `client` — The HTTP client to store in Svelte context.
1376
1360
 
1377
- #### `createI18nStoresFromProvider(provider)`
1361
+ #### `setStorageContext(provider)`
1378
1362
 
1379
- Create i18n stores from a specific provider.
1363
+ Sets the storage context.
1380
1364
 
1381
1365
  ```typescript
1382
- function createI18nStoresFromProvider(provider: I18nProvider): I18nStores
1366
+ function setStorageContext(provider: StorageProvider): void
1383
1367
  ```
1384
1368
 
1385
- - `provider` — I18n provider
1386
-
1387
- **Returns:** I18n stores and actions
1369
+ - `provider` — The storage provider to store in Svelte context.
1388
1370
 
1389
- #### `createIsActiveStore(location, router, path, exact)`
1371
+ #### `setLoggerContext(provider)`
1390
1372
 
1391
- Create a derived store that checks if a path is active.
1373
+ Sets the logger context.
1392
1374
 
1393
1375
  ```typescript
1394
- function createIsActiveStore(
1395
- location: Readable<RouteLocation>,
1396
- router: Router,
1397
- path: string,
1398
- exact?: boolean,
1399
- ): Readable<boolean>
1376
+ function setLoggerContext(provider: LoggerProvider): void
1400
1377
  ```
1401
1378
 
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
1379
+ - `provider` — The logger provider to store in Svelte context.
1408
1380
 
1409
- #### `createLogger(config)`
1381
+ #### `getStateProvider()`
1410
1382
 
1411
- Create a logger with custom configuration.
1383
+ Gets the state provider from Svelte context.
1412
1384
 
1413
1385
  ```typescript
1414
- function createLogger(config: LoggerConfig): Logger
1386
+ function getStateProvider(): StateProvider
1415
1387
  ```
1416
1388
 
1417
- - `config` — Logger configuration
1418
-
1419
- **Returns:** Logger instance
1389
+ **Returns:** The state provider instance.
1420
1390
 
1421
- #### `createLoggerHelpers()`
1391
+ #### `getAuthClient()`
1422
1392
 
1423
- Create logger helpers from context.
1393
+ Gets the auth client from Svelte context.
1424
1394
 
1425
1395
  ```typescript
1426
- function createLoggerHelpers(): LoggerHelpers
1396
+ function getAuthClient(): AuthClient<T, TRegister>
1427
1397
  ```
1428
1398
 
1429
- **Returns:** Logger helper functions
1399
+ **Returns:** The auth client instance.
1430
1400
 
1431
- #### `createLoggerHelpersFromProvider(provider)`
1401
+ #### `getThemeProvider()`
1432
1402
 
1433
- Create logger helpers from a specific provider.
1403
+ Gets the theme provider from Svelte context.
1434
1404
 
1435
1405
  ```typescript
1436
- function createLoggerHelpersFromProvider(provider: LoggerProvider): LoggerHelpers
1406
+ function getThemeProvider(): ThemeProvider
1437
1407
  ```
1438
1408
 
1439
- - `provider` — Logger provider
1440
-
1441
- **Returns:** Logger helper functions
1409
+ **Returns:** The theme provider instance.
1442
1410
 
1443
- #### `createLoginStore()`
1411
+ #### `getRouter()`
1444
1412
 
1445
- Creates a login store with async state tracking.
1413
+ Gets the router from Svelte context.
1446
1414
 
1447
1415
  ```typescript
1448
- function createLoginStore(): LoginStore<T>
1416
+ function getRouter(): Router
1449
1417
  ```
1450
1418
 
1451
- **Returns:** Login promise store
1452
-
1453
- #### `createOAuthHelpers(options)`
1454
-
1455
- Creates OAuth helpers for provider-based authentication flows.
1419
+ **Returns:** The router instance.
1456
1420
 
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).
1421
+ #### `getI18nProvider()`
1460
1422
 
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`.
1423
+ Gets the i18n provider from Svelte context.
1467
1424
 
1468
1425
  ```typescript
1469
- function createOAuthHelpers(options?: OAuthOptions): OAuthHelpers
1426
+ function getI18nProvider(): I18nProvider
1470
1427
  ```
1471
1428
 
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.
1429
+ **Returns:** The i18n provider instance.
1475
1430
 
1476
- #### `createPasswordResetStores()`
1431
+ #### `getHttpClient()`
1477
1432
 
1478
- Creates password reset stores with async state tracking.
1433
+ Gets the HTTP client from Svelte context.
1479
1434
 
1480
1435
  ```typescript
1481
- function createPasswordResetStores(): PasswordResetStores
1436
+ function getHttpClient(): HttpClient
1482
1437
  ```
1483
1438
 
1484
- **Returns:** Password reset stores for request and confirm steps
1439
+ **Returns:** The HTTP client instance.
1485
1440
 
1486
- #### `createPatchStore(url, config)`
1441
+ #### `getStorageProvider()`
1487
1442
 
1488
- Creates a PATCH request store.
1443
+ Gets the storage provider from Svelte context.
1489
1444
 
1490
1445
  ```typescript
1491
- function createPatchStore(url: string, config?: RequestConfig): HttpStore<T>
1446
+ function getStorageProvider(): StorageProvider
1492
1447
  ```
1493
1448
 
1494
- - `url` — The request endpoint URL.
1495
- - `config` — Optional request configuration such as headers or body data.
1449
+ **Returns:** The storage provider instance.
1496
1450
 
1497
- **Returns:** A subscribable HTTP store for the PATCH request with execute and reset methods.
1451
+ #### `getLoggerProvider()`
1498
1452
 
1499
- #### `createPlatformStores()`
1453
+ Gets the logger provider from Svelte context.
1500
1454
 
1501
- Create platform stores from the module-level platform info.
1455
+ ```typescript
1456
+ function getLoggerProvider(): LoggerProvider
1457
+ ```
1502
1458
 
1503
- Platform information is static (no reactive subscription needed),
1504
- so this returns plain values rather than Svelte stores.
1459
+ **Returns:** The logger provider instance.
1460
+
1461
+ #### `createAsyncState(initialValue)`
1462
+
1463
+ Creates a writable store with async-capable setState and extendState.
1505
1464
 
1506
1465
  ```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
- }
1466
+ function createAsyncState(initialValue: T): AsyncStateStore<T>
1517
1467
  ```
1518
1468
 
1519
- **Returns:** Platform information and utility functions
1469
+ - `initialValue` — The initial state value
1520
1470
 
1521
- #### `createPostStore(url, config)`
1471
+ **Returns:** The created instance.
1522
1472
 
1523
- Creates a POST request store.
1473
+ #### `createAuthStores()`
1474
+
1475
+ Create auth stores from the auth client in context.
1524
1476
 
1525
1477
  ```typescript
1526
- function createPostStore(url: string, config?: RequestConfig): HttpStore<T>
1478
+ function createAuthStores(): AuthStores<T, TRegister> & { error: Readable<string | null> }
1527
1479
  ```
1528
1480
 
1529
- - `url` — The request endpoint URL.
1530
- - `config` — Optional request configuration such as headers or body data.
1481
+ **Returns:** Auth stores and actions
1531
1482
 
1532
- **Returns:** A subscribable HTTP store for the POST request with execute and reset methods.
1483
+ #### `createAuthStoresFromClient(client)`
1533
1484
 
1534
- #### `createPromiseStore(asyncFn)`
1485
+ Create auth stores from a specific auth client.
1535
1486
 
1536
- Creates a store that tracks async function state.
1487
+ Use this when you don't want to use context.
1537
1488
 
1538
1489
  ```typescript
1539
- function createPromiseStore(asyncFn: T): PromiseStore<Awaited<ReturnType<T>>>
1490
+ function createAuthStoresFromClient(client: AuthClient<T, TRegister>): AuthStores<T, TRegister>
1540
1491
  ```
1541
1492
 
1542
- - `asyncFn` — The async function to track
1493
+ - `client` — Auth client
1543
1494
 
1544
- **Returns:** Promise store with subscribe, call, cancel, and reset
1495
+ **Returns:** Auth stores and actions
1545
1496
 
1546
- #### `createPushStores()`
1497
+ #### `createCapacitorAppStore(options)`
1547
1498
 
1548
- Create push notification stores from the module-level push provider.
1499
+ Create a Svelte store wrapping the Capacitor app coordinator.
1500
+
1501
+ Creates a CapacitorApp instance, subscribes to state changes,
1502
+ and auto-initializes. The returned store is readable and also
1503
+ exposes an `initialize` method for manual re-initialization.
1549
1504
 
1550
1505
  ```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>
1506
+ function createCapacitorAppStore(options?: CapacitorAppOptions): CapacitorAppStore
1507
+ ```
1508
+
1509
+ - `options` — Capacitor app options
1510
+
1511
+ **Returns:** A readable store of CapacitorAppState with an initialize method
1512
+
1513
+ #### `createChangePasswordStore()`
1514
+
1515
+ Creates a change password store with async state tracking.
1516
+
1517
+ ```typescript
1518
+ function createChangePasswordStore(): ChangePasswordStore
1519
+ ```
1520
+
1521
+ **Returns:** Change password promise store
1522
+
1523
+ #### `createDeviceStores()`
1524
+
1525
+ Create device stores from the module-level device provider.
1526
+
1527
+ Device information is static (no reactive subscription needed),
1528
+ so this returns plain values rather than Svelte stores.
1529
+
1530
+ ```typescript
1531
+ function createDeviceStores(): {
1532
+ deviceInfo: DeviceInfo
1533
+ screenInfo: ScreenInfo
1534
+ hardwareInfo: HardwareInfo
1535
+ featureSupport: FeatureSupport
1536
+ supports: (feature: keyof FeatureSupport) => boolean
1537
+ isOnline: () => boolean
1538
+ isStandalone: () => boolean
1539
+ language: string
1540
+ languages: string[]
1563
1541
  }
1564
1542
  ```
1565
1543
 
1566
- **Returns:** Push notification stores and actions
1544
+ **Returns:** Device information and utility functions
1567
1545
 
1568
- #### `createPutStore(url, config)`
1546
+ #### `createFormStores(provider, options)`
1569
1547
 
1570
- Creates a PUT request store.
1548
+ Create form stores from a form provider and options.
1571
1549
 
1572
1550
  ```typescript
1573
- function createPutStore(url: string, config?: RequestConfig): HttpStore<T>
1551
+ function createFormStores(provider: FormProvider, options: FormOptions<T>): FormStores<T>
1574
1552
  ```
1575
1553
 
1576
- - `url` — The request endpoint URL.
1577
- - `config` — Optional request configuration such as headers or body data.
1554
+ - `provider` — Form provider instance
1555
+ - `options` — Form creation options
1578
1556
 
1579
- **Returns:** A subscribable HTTP store for the PUT request with execute and reset methods.
1557
+ **Returns:** Form stores and actions
1580
1558
 
1581
- #### `createRouterStores()`
1559
+ #### `createFieldStore(controller, name)`
1582
1560
 
1583
- Create router stores from the router in context.
1561
+ Create a readable store that tracks a single field's state.
1584
1562
 
1585
1563
  ```typescript
1586
- function createRouterStores(): RouterStores
1564
+ function createFieldStore(controller: FormController<T>, name: K): Readable<FieldState<T[K]>>
1587
1565
  ```
1588
1566
 
1589
- **Returns:** Router stores and actions
1567
+ - `controller` — Form controller
1568
+ - `name` — Field name to track
1590
1569
 
1591
- #### `createRouterStoresFromRouter(router)`
1570
+ **Returns:** Readable store of the field state
1592
1571
 
1593
- Create router stores from a specific router.
1572
+ #### `createWatchStore(controller, name)`
1573
+
1574
+ Create a readable store that tracks a single field's value.
1594
1575
 
1595
1576
  ```typescript
1596
- function createRouterStoresFromRouter(router: Router): RouterStores
1577
+ function createWatchStore(controller: FormController<T>, name: K): Readable<T[K]>
1597
1578
  ```
1598
1579
 
1599
- - `router` — Router instance
1580
+ - `controller` — Form controller
1581
+ - `name` — Field name to watch
1600
1582
 
1601
- **Returns:** Router stores and actions
1583
+ **Returns:** Readable store of the field value
1602
1584
 
1603
- #### `createSignupStore()`
1585
+ #### `createHttpStore(method, url, config)`
1604
1586
 
1605
- Creates a signup store with async state tracking.
1587
+ Create an HTTP request store.
1606
1588
 
1607
1589
  ```typescript
1608
- function createSignupStore(): SignupStore<T>
1590
+ function createHttpStore(
1591
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
1592
+ url: string,
1593
+ config?: RequestConfig,
1594
+ ): HttpStore<T>
1609
1595
  ```
1610
1596
 
1611
- **Returns:** Signup promise store
1597
+ - `method` — HTTP method
1598
+ - `url` — Request URL
1599
+ - `config` — Request configuration
1612
1600
 
1613
- #### `createStorageHelpers()`
1601
+ **Returns:** Store with state and actions
1614
1602
 
1615
- Create storage helper functions from context.
1603
+ #### `createGetStore(url, config)`
1604
+
1605
+ Creates a GET request store.
1616
1606
 
1617
1607
  ```typescript
1618
- function createStorageHelpers(): StorageHelpers
1608
+ function createGetStore(url: string, config?: RequestConfig): HttpStore<T>
1619
1609
  ```
1620
1610
 
1621
- **Returns:** Storage functions
1611
+ - `url` — The request endpoint URL.
1612
+ - `config` — Optional request configuration such as headers or params.
1622
1613
 
1623
- #### `createStorageStore(key, defaultValue)`
1614
+ **Returns:** A subscribable HTTP store for the GET request with execute and reset methods.
1624
1615
 
1625
- Create a storage value store.
1616
+ #### `createPostStore(url, config)`
1617
+
1618
+ Creates a POST request store.
1626
1619
 
1627
1620
  ```typescript
1628
- function createStorageStore(key: string, defaultValue?: T): StorageStore<T>
1621
+ function createPostStore(url: string, config?: RequestConfig): HttpStore<T>
1629
1622
  ```
1630
1623
 
1631
- - `key` — Storage key
1632
- - `defaultValue` — Default value if not found
1624
+ - `url` — The request endpoint URL.
1625
+ - `config` — Optional request configuration such as headers or body data.
1633
1626
 
1634
- **Returns:** Store with value and actions
1627
+ **Returns:** A subscribable HTTP store for the POST request with execute and reset methods.
1635
1628
 
1636
- #### `createStorageStoreFromProvider(storage, key, defaultValue)`
1629
+ #### `createPutStore(url, config)`
1637
1630
 
1638
- Create storage store from a specific provider.
1631
+ Creates a PUT request store.
1639
1632
 
1640
1633
  ```typescript
1641
- function createStorageStoreFromProvider(
1642
- storage: StorageProvider,
1643
- key: string,
1644
- defaultValue?: T,
1645
- ): StorageStore<T>
1634
+ function createPutStore(url: string, config?: RequestConfig): HttpStore<T>
1646
1635
  ```
1647
1636
 
1648
- - `storage` — Storage provider
1649
- - `key` — Storage key
1650
- - `defaultValue` — Default value
1637
+ - `url` — The request endpoint URL.
1638
+ - `config` — Optional request configuration such as headers or body data.
1651
1639
 
1652
- **Returns:** Store with value and actions
1640
+ **Returns:** A subscribable HTTP store for the PUT request with execute and reset methods.
1653
1641
 
1654
- #### `createStoreAction(store, action)`
1642
+ #### `createPatchStore(url, config)`
1655
1643
 
1656
- Create a bound action for a store.
1644
+ Creates a PATCH request store.
1657
1645
 
1658
1646
  ```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
1647
+ function createPatchStore(url: string, config?: RequestConfig): HttpStore<T>
1666
1648
  ```
1667
1649
 
1668
- - `store` — The store
1669
- - `action` — Action creator function
1650
+ - `url` — The request endpoint URL.
1651
+ - `config` — Optional request configuration such as headers or body data.
1670
1652
 
1671
- **Returns:** Bound action
1653
+ **Returns:** A subscribable HTTP store for the PATCH request with execute and reset methods.
1672
1654
 
1673
- #### `createStoreReadable(store)`
1655
+ #### `createDeleteStore(url, config)`
1674
1656
 
1675
- Create a readable Svelte store from a molecule store.
1657
+ Creates a DELETE request store.
1676
1658
 
1677
1659
  ```typescript
1678
- function createStoreReadable(store: MoleculeStore<T>): Readable<T>
1660
+ function createDeleteStore(url: string, config?: RequestConfig): HttpStore<T>
1679
1661
  ```
1680
1662
 
1681
- - `store` — The molecule store
1663
+ - `url` — The request endpoint URL.
1664
+ - `config` — Optional request configuration such as headers or params.
1682
1665
 
1683
- **Returns:** Readable Svelte store
1666
+ **Returns:** A subscribable HTTP store for the DELETE request with execute and reset methods.
1684
1667
 
1685
- #### `createStoreSelector(store, selector)`
1668
+ #### `createHttpStoresFromClient(client)`
1686
1669
 
1687
- Create a derived Svelte store with a selector.
1670
+ Creates HTTP store factory methods bound to a specific client instance.
1688
1671
 
1689
1672
  ```typescript
1690
- function createStoreSelector(store: MoleculeStore<T>, selector: (state: T) => S): Readable<S>
1673
+ function createHttpStoresFromClient(client: HttpClient): HttpStoreFactory
1691
1674
  ```
1692
1675
 
1693
- - `store` — The molecule store
1694
- - `selector` — Selector function
1676
+ - `client` — The HTTP client to use for all created stores.
1695
1677
 
1696
- **Returns:** Derived Svelte store
1678
+ **Returns:** An object with get, post, put, patch, and delete factory methods.
1697
1679
 
1698
- #### `createThemeColorsStore(theme)`
1680
+ #### `createI18nStores()`
1699
1681
 
1700
- Create a derived store that returns just the theme colors.
1682
+ Create i18n stores from the i18n provider in context.
1701
1683
 
1702
1684
  ```typescript
1703
- function createThemeColorsStore(theme: Readable<Theme>): Readable<ThemeColors>
1685
+ function createI18nStores(): I18nStores
1704
1686
  ```
1705
1687
 
1706
- - `theme` — A readable theme store (from createThemeStores or createThemeStoresFromProvider)
1688
+ **Returns:** I18n stores and actions
1707
1689
 
1708
- **Returns:** Readable store of theme colors
1690
+ #### `createI18nStoresFromProvider(provider)`
1709
1691
 
1710
- #### `createThemeStores()`
1692
+ Create i18n stores from a specific provider.
1711
1693
 
1712
- Create theme stores from the theme provider in context.
1694
+ ```typescript
1695
+ function createI18nStoresFromProvider(provider: I18nProvider): I18nStores
1696
+ ```
1697
+
1698
+ - `provider` — I18n provider
1699
+
1700
+ **Returns:** I18n stores and actions
1701
+
1702
+ #### `getLogger(name)`
1703
+
1704
+ Get a logger instance.
1713
1705
 
1714
1706
  ```typescript
1715
- function createThemeStores(): ThemeStores & { colors: Readable<Theme['colors']> }
1707
+ function getLogger(name?: string): Logger
1716
1708
  ```
1717
1709
 
1718
- **Returns:** Theme stores and actions
1710
+ - `name` — Logger name
1719
1711
 
1720
- #### `createThemeStoresFromProvider(provider)`
1712
+ **Returns:** Logger instance
1721
1713
 
1722
- Create theme stores from a specific theme provider.
1714
+ #### `createLogger(config)`
1715
+
1716
+ Create a logger with custom configuration.
1723
1717
 
1724
1718
  ```typescript
1725
- function createThemeStoresFromProvider(provider: ThemeProvider): ThemeStores
1719
+ function createLogger(config: LoggerConfig): Logger
1726
1720
  ```
1727
1721
 
1728
- - `provider` — Theme provider
1722
+ - `config` — Logger configuration
1729
1723
 
1730
- **Returns:** Theme stores and actions
1724
+ **Returns:** Logger instance
1731
1725
 
1732
- #### `createVersionStores()`
1726
+ #### `getRootLogger()`
1733
1727
 
1734
- Create version stores from the module-level version provider.
1728
+ Get the root logger.
1735
1729
 
1736
1730
  ```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
- }
1731
+ function getRootLogger(): Logger
1749
1732
  ```
1750
1733
 
1751
- **Returns:** Version stores and actions
1734
+ **Returns:** Root logger instance
1752
1735
 
1753
- #### `createWatchStore(controller, name)`
1736
+ #### `getChildLogger(name, context)`
1754
1737
 
1755
- Create a readable store that tracks a single field's value.
1738
+ Create a child logger with additional context.
1756
1739
 
1757
1740
  ```typescript
1758
- function createWatchStore(controller: FormController<T>, name: K): Readable<T[K]>
1741
+ function getChildLogger(name: string, context: Record<string, unknown>): Logger
1759
1742
  ```
1760
1743
 
1761
- - `controller` — Form controller
1762
- - `name` — Field name to watch
1744
+ - `name` — Parent logger name
1745
+ - `context` — Additional context
1763
1746
 
1764
- **Returns:** Readable store of the field value
1747
+ **Returns:** Child logger instance
1765
1748
 
1766
- #### `getAuthClient()`
1749
+ #### `createLoggerHelpers()`
1767
1750
 
1768
- Gets the auth client from Svelte context.
1751
+ Create logger helpers from context.
1769
1752
 
1770
1753
  ```typescript
1771
- function getAuthClient(): AuthClient<T>
1754
+ function createLoggerHelpers(): LoggerHelpers
1772
1755
  ```
1773
1756
 
1774
- **Returns:** The auth client instance.
1757
+ **Returns:** Logger helper functions
1758
+
1759
+ #### `createLoggerHelpersFromProvider(provider)`
1760
+
1761
+ Create logger helpers from a specific provider.
1762
+
1763
+ ```typescript
1764
+ function createLoggerHelpersFromProvider(provider: LoggerProvider): LoggerHelpers
1765
+ ```
1766
+
1767
+ - `provider` — Logger provider
1768
+
1769
+ **Returns:** Logger helper functions
1770
+
1771
+ #### `createLoginStore()`
1772
+
1773
+ Creates a login store with async state tracking.
1774
+
1775
+ ```typescript
1776
+ function createLoginStore(): LoginStore<T>
1777
+ ```
1778
+
1779
+ **Returns:** Login promise store
1780
+
1781
+ #### `createOAuthHelpers(options)`
1782
+
1783
+ Creates OAuth helpers for provider-based authentication flows.
1775
1784
 
1776
- #### `getChildLogger(name, context)`
1785
+ When created in a browser, automatically handles OAuth callbacks by
1786
+ detecting `code` and `state` URL parameters and exchanging them for a
1787
+ session (a guarded no-op when there is no callback code in the URL).
1777
1788
 
1778
- Create a child logger with additional context.
1789
+ Session establishment: the exchange result is applied to the resolved auth
1790
+ client (an explicit `options.authClient`, else the Svelte-context client
1791
+ when created during component initialization). When NO client is available,
1792
+ the server has already established the httpOnly-cookie session via the
1793
+ exchange, so a user-carrying response still counts as success —
1794
+ `options.onSuccess` fires; a response with no user fires `options.onError`.
1779
1795
 
1780
1796
  ```typescript
1781
- function getChildLogger(name: string, context: Record<string, unknown>): Logger
1797
+ function createOAuthHelpers(options?: OAuthOptions): OAuthHelpers
1782
1798
  ```
1783
1799
 
1784
- - `name` — Parent logger name
1785
- - `context` — Additional context
1800
+ - `options` — OAuth configuration (base URL, providers, endpoint paths, callbacks, auth client).
1786
1801
 
1787
- **Returns:** Child logger instance
1802
+ **Returns:** An object containing a readable providers store, URL builder, redirect function, and callback handler.
1788
1803
 
1789
- #### `getHttpClient()`
1804
+ #### `createPasswordResetStores()`
1790
1805
 
1791
- Gets the HTTP client from Svelte context.
1806
+ Creates password reset stores with async state tracking.
1792
1807
 
1793
1808
  ```typescript
1794
- function getHttpClient(): HttpClient
1809
+ function createPasswordResetStores(): PasswordResetStores
1795
1810
  ```
1796
1811
 
1797
- **Returns:** The HTTP client instance.
1812
+ **Returns:** Password reset stores for request and confirm steps
1798
1813
 
1799
- #### `getI18nProvider()`
1814
+ #### `createPlatformStores()`
1800
1815
 
1801
- Gets the i18n provider from Svelte context.
1816
+ Create platform stores from the module-level platform info.
1817
+
1818
+ Platform information is static (no reactive subscription needed),
1819
+ so this returns plain values rather than Svelte stores.
1802
1820
 
1803
1821
  ```typescript
1804
- function getI18nProvider(): I18nProvider
1822
+ function createPlatformStores(): {
1823
+ platform: Platform
1824
+ isNative: boolean
1825
+ isMobile: boolean
1826
+ isDesktop: boolean
1827
+ isWeb: boolean
1828
+ isDevelopment: boolean
1829
+ isProduction: boolean
1830
+ isPlatform: (...platforms: Platform[]) => boolean
1831
+ }
1805
1832
  ```
1806
1833
 
1807
- **Returns:** The i18n provider instance.
1834
+ **Returns:** Platform information and utility functions
1808
1835
 
1809
- #### `getLogger(name)`
1836
+ #### `createPromiseStore(asyncFn)`
1810
1837
 
1811
- Get a logger instance.
1838
+ Creates a store that tracks async function state.
1812
1839
 
1813
1840
  ```typescript
1814
- function getLogger(name?: string): Logger
1841
+ function createPromiseStore(asyncFn: T): PromiseStore<Awaited<ReturnType<T>>>
1815
1842
  ```
1816
1843
 
1817
- - `name` — Logger name
1844
+ - `asyncFn` — The async function to track
1818
1845
 
1819
- **Returns:** Logger instance
1846
+ **Returns:** Promise store with subscribe, call, cancel, and reset
1820
1847
 
1821
- #### `getLoggerProvider()`
1848
+ #### `createPushStores()`
1822
1849
 
1823
- Gets the logger provider from Svelte context.
1850
+ Create push notification stores from the module-level push provider.
1824
1851
 
1825
1852
  ```typescript
1826
- function getLoggerProvider(): LoggerProvider
1853
+ function createPushStores(): {
1854
+ permission: Readable<PermissionStatus | null>
1855
+ token: Readable<PushToken | null>
1856
+ checkPermission: () => Promise<PermissionStatus>
1857
+ requestPermission: () => Promise<PermissionStatus>
1858
+ register: (options?: PushRegisterOptions) => Promise<PushToken>
1859
+ unregister: () => Promise<void>
1860
+ onNotificationReceived: (listener: NotificationReceivedListener) => () => void
1861
+ onNotificationAction: (listener: NotificationActionListener) => () => void
1862
+ onTokenChange: (listener: TokenChangeListener) => () => void
1863
+ setBadge: (count: number) => Promise<void>
1864
+ clearBadge: () => Promise<void>
1865
+ }
1827
1866
  ```
1828
1867
 
1829
- **Returns:** The logger provider instance.
1868
+ **Returns:** Push notification stores and actions
1830
1869
 
1831
- #### `getRootLogger()`
1870
+ #### `createRouterStores()`
1832
1871
 
1833
- Get the root logger.
1872
+ Create router stores from the router in context.
1834
1873
 
1835
1874
  ```typescript
1836
- function getRootLogger(): Logger
1875
+ function createRouterStores(): RouterStores
1837
1876
  ```
1838
1877
 
1839
- **Returns:** Root logger instance
1878
+ **Returns:** Router stores and actions
1840
1879
 
1841
- #### `getRouter()`
1880
+ #### `createIsActiveStore(location, router, path, exact)`
1842
1881
 
1843
- Gets the router from Svelte context.
1882
+ Create a derived store that checks if a path is active.
1844
1883
 
1845
1884
  ```typescript
1846
- function getRouter(): Router
1885
+ function createIsActiveStore(
1886
+ location: Readable<RouteLocation>,
1887
+ router: Router,
1888
+ path: string,
1889
+ exact?: boolean,
1890
+ ): Readable<boolean>
1847
1891
  ```
1848
1892
 
1849
- **Returns:** The router instance.
1893
+ - `location` — A readable location store (from createRouterStores or createRouterStoresFromRouter)
1894
+ - `router` — Router instance (for isActive check)
1895
+ - `path` — Path to check
1896
+ - `exact` — Whether to require exact match (default: false)
1850
1897
 
1851
- #### `getSetStore(store)`
1898
+ **Returns:** Readable store of whether the path is active
1852
1899
 
1853
- Get the setState function from a molecule store.
1900
+ #### `createRouterStoresFromRouter(router)`
1901
+
1902
+ Create router stores from a specific router.
1854
1903
 
1855
1904
  ```typescript
1856
- function getSetStore(
1857
- store: MoleculeStore<T>,
1858
- ): (partial: Partial<T> | ((state: T) => Partial<T>)) => void
1905
+ function createRouterStoresFromRouter(router: Router): RouterStores
1859
1906
  ```
1860
1907
 
1861
- - `store` — The molecule store
1908
+ - `router` — Router instance
1862
1909
 
1863
- **Returns:** setState function
1910
+ **Returns:** Router stores and actions
1864
1911
 
1865
- #### `getStateProvider()`
1912
+ #### `createSignupStore()`
1866
1913
 
1867
- Gets the state provider from Svelte context.
1914
+ Creates a signup store with async state tracking.
1868
1915
 
1869
1916
  ```typescript
1870
- function getStateProvider(): StateProvider
1917
+ function createSignupStore(): SignupStore<T>
1871
1918
  ```
1872
1919
 
1873
- **Returns:** The state provider instance.
1920
+ **Returns:** Signup promise store
1874
1921
 
1875
- #### `getStorageProvider()`
1922
+ #### `createStoreReadable(store)`
1876
1923
 
1877
- Gets the storage provider from Svelte context.
1924
+ Create a readable Svelte store from a molecule store.
1878
1925
 
1879
1926
  ```typescript
1880
- function getStorageProvider(): StorageProvider
1927
+ function createStoreReadable(store: MoleculeStore<T>): Readable<T>
1881
1928
  ```
1882
1929
 
1883
- **Returns:** The storage provider instance.
1930
+ - `store` — The molecule store
1884
1931
 
1885
- #### `getThemeProvider()`
1932
+ **Returns:** Readable Svelte store
1886
1933
 
1887
- Gets the theme provider from Svelte context.
1934
+ #### `createStoreSelector(store, selector)`
1935
+
1936
+ Create a derived Svelte store with a selector.
1888
1937
 
1889
1938
  ```typescript
1890
- function getThemeProvider(): ThemeProvider
1939
+ function createStoreSelector(store: MoleculeStore<T>, selector: (state: T) => S): Readable<S>
1891
1940
  ```
1892
1941
 
1893
- **Returns:** The theme provider instance.
1942
+ - `store` — The molecule store
1943
+ - `selector` — Selector function
1894
1944
 
1895
- #### `setAuthContext(client)`
1945
+ **Returns:** Derived Svelte store
1896
1946
 
1897
- Sets the auth context.
1947
+ #### `getSetStore(store)`
1948
+
1949
+ Get the setState function from a molecule store.
1898
1950
 
1899
1951
  ```typescript
1900
- function setAuthContext(client: AuthClient<T>): void
1952
+ function getSetStore(
1953
+ store: MoleculeStore<T>,
1954
+ ): (partial: Partial<T> | ((state: T) => Partial<T>)) => void
1901
1955
  ```
1902
1956
 
1903
- - `client` — The auth client to store in Svelte context.
1957
+ - `store` — The molecule store
1904
1958
 
1905
- #### `setHttpContext(client)`
1959
+ **Returns:** setState function
1906
1960
 
1907
- Sets the HTTP context.
1961
+ #### `createStoreAction(store, action)`
1962
+
1963
+ Create a bound action for a store.
1908
1964
 
1909
1965
  ```typescript
1910
- function setHttpContext(client: HttpClient): void
1966
+ function createStoreAction(
1967
+ store: MoleculeStore<T>,
1968
+ action: (
1969
+ setState: MoleculeStore<T>['setState'],
1970
+ getState: MoleculeStore<T>['getState'],
1971
+ ) => (...args: Args) => R,
1972
+ ): (...args: Args) => R
1911
1973
  ```
1912
1974
 
1913
- - `client` — The HTTP client to store in Svelte context.
1975
+ - `store` — The store
1976
+ - `action` — Action creator function
1914
1977
 
1915
- #### `setI18nContext(provider)`
1978
+ **Returns:** Bound action
1916
1979
 
1917
- Sets the i18n context.
1980
+ #### `createStorageStore(key, defaultValue)`
1981
+
1982
+ Create a storage value store.
1918
1983
 
1919
1984
  ```typescript
1920
- function setI18nContext(provider: I18nProvider): void
1985
+ function createStorageStore(key: string, defaultValue?: T): StorageStore<T>
1921
1986
  ```
1922
1987
 
1923
- - `provider` — The i18n provider to store in Svelte context.
1988
+ - `key` — Storage key
1989
+ - `defaultValue` — Default value if not found
1924
1990
 
1925
- #### `setLoggerContext(provider)`
1991
+ **Returns:** Store with value and actions
1926
1992
 
1927
- Sets the logger context.
1993
+ #### `createStorageHelpers()`
1994
+
1995
+ Create storage helper functions from context.
1928
1996
 
1929
1997
  ```typescript
1930
- function setLoggerContext(provider: LoggerProvider): void
1998
+ function createStorageHelpers(): StorageHelpers
1931
1999
  ```
1932
2000
 
1933
- - `provider` — The logger provider to store in Svelte context.
1934
-
1935
- #### `setMoleculeContext(config)`
2001
+ **Returns:** Storage functions
1936
2002
 
1937
- Set all molecule providers in Svelte context.
2003
+ #### `createStorageStoreFromProvider(storage, key, defaultValue)`
1938
2004
 
1939
- Call this in your root layout/component.
2005
+ Create storage store from a specific provider.
1940
2006
 
1941
2007
  ```typescript
1942
- function setMoleculeContext(config: MoleculeConfig): void
2008
+ function createStorageStoreFromProvider(
2009
+ storage: StorageProvider,
2010
+ key: string,
2011
+ defaultValue?: T,
2012
+ ): StorageStore<T>
1943
2013
  ```
1944
2014
 
1945
- - `config` — Provider instances to register (state, auth, theme, router, i18n, http, storage, logger).
2015
+ - `storage` — Storage provider
2016
+ - `key` — Storage key
2017
+ - `defaultValue` — Default value
1946
2018
 
1947
- #### `setRouterContext(router)`
2019
+ **Returns:** Store with value and actions
1948
2020
 
1949
- Sets the router context.
2021
+ #### `createThemeStores()`
2022
+
2023
+ Create theme stores from the theme provider in context.
1950
2024
 
1951
2025
  ```typescript
1952
- function setRouterContext(router: Router): void
2026
+ function createThemeStores(): ThemeStores & { colors: Readable<Theme['colors']> }
1953
2027
  ```
1954
2028
 
1955
- - `router` — The router instance to store in Svelte context.
2029
+ **Returns:** Theme stores and actions
1956
2030
 
1957
- #### `setStateContext(provider)`
2031
+ #### `createThemeColorsStore(theme)`
1958
2032
 
1959
- Sets the state context.
2033
+ Create a derived store that returns just the theme colors.
1960
2034
 
1961
2035
  ```typescript
1962
- function setStateContext(provider: StateProvider): void
2036
+ function createThemeColorsStore(theme: Readable<Theme>): Readable<ThemeColors>
1963
2037
  ```
1964
2038
 
1965
- - `provider` — The state provider to store in Svelte context.
2039
+ - `theme` — A readable theme store (from createThemeStores or createThemeStoresFromProvider)
1966
2040
 
1967
- #### `setStorageContext(provider)`
2041
+ **Returns:** Readable store of theme colors
1968
2042
 
1969
- Sets the storage context.
2043
+ #### `createThemeStoresFromProvider(provider)`
2044
+
2045
+ Create theme stores from a specific theme provider.
1970
2046
 
1971
2047
  ```typescript
1972
- function setStorageContext(provider: StorageProvider): void
2048
+ function createThemeStoresFromProvider(provider: ThemeProvider): ThemeStores
1973
2049
  ```
1974
2050
 
1975
- - `provider` — The storage provider to store in Svelte context.
2051
+ - `provider` — Theme provider
1976
2052
 
1977
- #### `setThemeContext(provider)`
2053
+ **Returns:** Theme stores and actions
1978
2054
 
1979
- Sets the theme context.
2055
+ #### `createVersionStores()`
2056
+
2057
+ Create version stores from the module-level version provider.
1980
2058
 
1981
2059
  ```typescript
1982
- function setThemeContext(provider: ThemeProvider): void
2060
+ function createVersionStores(): {
2061
+ state: Readable<VersionState>
2062
+ isUpdateAvailable: Readable<boolean>
2063
+ isChecking: Readable<boolean>
2064
+ isServiceWorkerWaiting: Readable<boolean>
2065
+ newVersion: Readable<string | undefined>
2066
+ checkForUpdates: () => Promise<boolean>
2067
+ applyUpdate: (options?: { force?: boolean }) => void
2068
+ dismissUpdate: () => void
2069
+ startPeriodicChecks: (options?: UpdateCheckOptions) => void
2070
+ stopPeriodicChecks: () => void
2071
+ }
1983
2072
  ```
1984
2073
 
1985
- - `provider` — The theme provider to store in Svelte context.
2074
+ **Returns:** Version stores and actions
1986
2075
 
1987
2076
  ## Injection Notes
1988
2077