@molecule/app-solid 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +115 -0
- package/README.md +2543 -0
- package/dist/context.d.ts +82 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +141 -0
- package/dist/context.js.map +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/primitives/async-state.d.ts +46 -0
- package/dist/primitives/async-state.d.ts.map +1 -0
- package/dist/primitives/async-state.js +83 -0
- package/dist/primitives/async-state.js.map +1 -0
- package/dist/primitives/auth.d.ts +85 -0
- package/dist/primitives/auth.d.ts.map +1 -0
- package/dist/primitives/auth.js +147 -0
- package/dist/primitives/auth.js.map +1 -0
- package/dist/primitives/capacitor-app.d.ts +46 -0
- package/dist/primitives/capacitor-app.d.ts.map +1 -0
- package/dist/primitives/capacitor-app.js +57 -0
- package/dist/primitives/capacitor-app.js.map +1 -0
- package/dist/primitives/change-password.d.ts +36 -0
- package/dist/primitives/change-password.d.ts.map +1 -0
- package/dist/primitives/change-password.js +32 -0
- package/dist/primitives/change-password.js.map +1 -0
- package/dist/primitives/device.d.ts +48 -0
- package/dist/primitives/device.d.ts.map +1 -0
- package/dist/primitives/device.js +47 -0
- package/dist/primitives/device.js.map +1 -0
- package/dist/primitives/forms.d.ts +193 -0
- package/dist/primitives/forms.d.ts.map +1 -0
- package/dist/primitives/forms.js +309 -0
- package/dist/primitives/forms.js.map +1 -0
- package/dist/primitives/http.d.ts +176 -0
- package/dist/primitives/http.d.ts.map +1 -0
- package/dist/primitives/http.js +254 -0
- package/dist/primitives/http.js.map +1 -0
- package/dist/primitives/i18n.d.ts +146 -0
- package/dist/primitives/i18n.d.ts.map +1 -0
- package/dist/primitives/i18n.js +223 -0
- package/dist/primitives/i18n.js.map +1 -0
- package/dist/primitives/index.d.ts +27 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +27 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/logger.d.ts +143 -0
- package/dist/primitives/logger.d.ts.map +1 -0
- package/dist/primitives/logger.js +165 -0
- package/dist/primitives/logger.js.map +1 -0
- package/dist/primitives/login.d.ts +37 -0
- package/dist/primitives/login.d.ts.map +1 -0
- package/dist/primitives/login.js +32 -0
- package/dist/primitives/login.js.map +1 -0
- package/dist/primitives/oauth.d.ts +102 -0
- package/dist/primitives/oauth.d.ts.map +1 -0
- package/dist/primitives/oauth.js +232 -0
- package/dist/primitives/oauth.js.map +1 -0
- package/dist/primitives/password-reset.d.ts +46 -0
- package/dist/primitives/password-reset.d.ts.map +1 -0
- package/dist/primitives/password-reset.js +49 -0
- package/dist/primitives/password-reset.js.map +1 -0
- package/dist/primitives/platform.d.ts +48 -0
- package/dist/primitives/platform.d.ts.map +1 -0
- package/dist/primitives/platform.js +47 -0
- package/dist/primitives/platform.js.map +1 -0
- package/dist/primitives/promise.d.ts +46 -0
- package/dist/primitives/promise.d.ts.map +1 -0
- package/dist/primitives/promise.js +104 -0
- package/dist/primitives/promise.js.map +1 -0
- package/dist/primitives/push.d.ts +52 -0
- package/dist/primitives/push.d.ts.map +1 -0
- package/dist/primitives/push.js +72 -0
- package/dist/primitives/push.js.map +1 -0
- package/dist/primitives/router.d.ts +170 -0
- package/dist/primitives/router.d.ts.map +1 -0
- package/dist/primitives/router.js +251 -0
- package/dist/primitives/router.js.map +1 -0
- package/dist/primitives/signup.d.ts +37 -0
- package/dist/primitives/signup.d.ts.map +1 -0
- package/dist/primitives/signup.js +32 -0
- package/dist/primitives/signup.js.map +1 -0
- package/dist/primitives/state.d.ts +132 -0
- package/dist/primitives/state.d.ts.map +1 -0
- package/dist/primitives/state.js +167 -0
- package/dist/primitives/state.js.map +1 -0
- package/dist/primitives/storage.d.ts +132 -0
- package/dist/primitives/storage.d.ts.map +1 -0
- package/dist/primitives/storage.js +275 -0
- package/dist/primitives/storage.js.map +1 -0
- package/dist/primitives/theme.d.ts +106 -0
- package/dist/primitives/theme.d.ts.map +1 -0
- package/dist/primitives/theme.js +187 -0
- package/dist/primitives/theme.js.map +1 -0
- package/dist/primitives/version.d.ts +50 -0
- package/dist/primitives/version.d.ts.map +1 -0
- package/dist/primitives/version.js +62 -0
- package/dist/primitives/version.js.map +1 -0
- package/dist/provider.d.ts +36 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.jsx +71 -0
- package/dist/provider.jsx.map +1 -0
- package/dist/types.d.ts +82 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,2543 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
3
|
+
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
|
+
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
|
+
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
+
Generated: 2026-08-04T00:41:07.786Z
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
# @molecule/app-solid
|
|
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
|
+
Solid.js framework bindings for molecule.dev.
|
|
16
|
+
|
|
17
|
+
Provides Solid-specific implementations of molecule.dev core interfaces
|
|
18
|
+
using Solid's reactive primitives (signals, effects, resources): wrap the
|
|
19
|
+
app in `MoleculeProvider` with a `config` of providers, then consume them
|
|
20
|
+
through `createAuth`, `createTheme`, `createRouter`, `createI18n`, and the
|
|
21
|
+
other primitives.
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { MoleculeProvider, createAuth, createTheme } from '@molecule/app-solid'
|
|
27
|
+
import { Show } from 'solid-js'
|
|
28
|
+
import { provider as stateProvider } from '@molecule/app-state-zustand'
|
|
29
|
+
import { provider as themeProvider } from '@molecule/app-theme-css-variables'
|
|
30
|
+
import { createJWTAuthClient } from '@molecule/app-auth'
|
|
31
|
+
|
|
32
|
+
const authClient = createJWTAuthClient({ baseURL: '/api' })
|
|
33
|
+
|
|
34
|
+
function UserProfile() {
|
|
35
|
+
const { user, isAuthenticated, logout } = createAuth<{ name?: string }>()
|
|
36
|
+
const { theme, toggleTheme } = createTheme()
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Show when={isAuthenticated()} fallback={<a href="/login">Log in</a>}>
|
|
40
|
+
<div style={{ background: theme().colors.background }}>
|
|
41
|
+
<h1>Welcome, {user()?.name}</h1>
|
|
42
|
+
<button onClick={toggleTheme}>Toggle Theme</button>
|
|
43
|
+
<button onClick={() => logout()}>Logout</button>
|
|
44
|
+
</div>
|
|
45
|
+
</Show>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function App() {
|
|
50
|
+
return (
|
|
51
|
+
<MoleculeProvider config={{ state: stateProvider, auth: authClient, theme: themeProvider }}>
|
|
52
|
+
<UserProfile />
|
|
53
|
+
</MoleculeProvider>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Type
|
|
59
|
+
|
|
60
|
+
`framework`
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npm install @molecule/app-solid @molecule/app-auth @molecule/app-device @molecule/app-forms @molecule/app-http @molecule/app-i18n @molecule/app-logger @molecule/app-platform @molecule/app-push @molecule/app-routing @molecule/app-state @molecule/app-storage @molecule/app-theme @molecule/app-ui @molecule/app-utilities @molecule/app-version solid-js
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## API
|
|
69
|
+
|
|
70
|
+
### Interfaces
|
|
71
|
+
|
|
72
|
+
#### `AuthClient`
|
|
73
|
+
|
|
74
|
+
Auth client interface that all auth bond packages must implement.
|
|
75
|
+
Provides login/logout/register flows, token management, profile
|
|
76
|
+
updates, and auth state subscription.
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
interface AuthClient<T = UserProfile> {
|
|
80
|
+
/**
|
|
81
|
+
* Returns the current authentication state snapshot.
|
|
82
|
+
*/
|
|
83
|
+
getState(): AuthState<T>
|
|
84
|
+
/**
|
|
85
|
+
* Returns whether the user is currently authenticated.
|
|
86
|
+
*/
|
|
87
|
+
isAuthenticated(): boolean
|
|
88
|
+
/**
|
|
89
|
+
* Gets the current user.
|
|
90
|
+
*/
|
|
91
|
+
getUser(): T | null
|
|
92
|
+
/**
|
|
93
|
+
* Updates the cached user object (state + persistent storage) without
|
|
94
|
+
* hitting the network. Intended for local refreshes after a per-app
|
|
95
|
+
* mutation (e.g., the user just PATCHed their own profile and the
|
|
96
|
+
* server returned the canonical row). Does NOT change tokens.
|
|
97
|
+
*/
|
|
98
|
+
setUser(user: T | null): void
|
|
99
|
+
/**
|
|
100
|
+
* Gets the current access token.
|
|
101
|
+
*/
|
|
102
|
+
getAccessToken(): string | null
|
|
103
|
+
/**
|
|
104
|
+
* Stores the access token in the configured token storage adapter (in-memory
|
|
105
|
+
* by default). Use this to seed the token after an out-of-band exchange (e.g.
|
|
106
|
+
* the OAuth code→token redirect) instead of writing to `localStorage` directly,
|
|
107
|
+
* which would violate the in-memory-default storage contract and make the bearer
|
|
108
|
+
* token JS-readable (XSS-exfiltratable). Pass `null` to clear it.
|
|
109
|
+
*/
|
|
110
|
+
setAccessToken(token: string | null): void
|
|
111
|
+
/**
|
|
112
|
+
* Gets the refresh token.
|
|
113
|
+
*/
|
|
114
|
+
getRefreshToken(): string | null
|
|
115
|
+
/**
|
|
116
|
+
* Logs in with credentials.
|
|
117
|
+
*/
|
|
118
|
+
login(credentials: LoginCredentials): Promise<AuthResult<T>>
|
|
119
|
+
/**
|
|
120
|
+
* Logs out the current user.
|
|
121
|
+
*/
|
|
122
|
+
logout(): Promise<void>
|
|
123
|
+
/**
|
|
124
|
+
* Registers a new user.
|
|
125
|
+
*/
|
|
126
|
+
register(data: RegisterData): Promise<AuthResult<T>>
|
|
127
|
+
/**
|
|
128
|
+
* Refreshes the access token.
|
|
129
|
+
*/
|
|
130
|
+
refresh(): Promise<AuthResult<T>>
|
|
131
|
+
/**
|
|
132
|
+
* Requests a password reset.
|
|
133
|
+
*/
|
|
134
|
+
requestPasswordReset(data: PasswordResetRequest): Promise<void>
|
|
135
|
+
/**
|
|
136
|
+
* Confirms a password reset.
|
|
137
|
+
*/
|
|
138
|
+
confirmPasswordReset(data: PasswordResetConfirm): Promise<void>
|
|
139
|
+
/**
|
|
140
|
+
* Updates the current user's profile.
|
|
141
|
+
*/
|
|
142
|
+
updateProfile(data: Partial<T>): Promise<T>
|
|
143
|
+
/**
|
|
144
|
+
* Changes the current user's password.
|
|
145
|
+
*/
|
|
146
|
+
changePassword(oldPassword: string, newPassword: string): Promise<void>
|
|
147
|
+
/**
|
|
148
|
+
* Initializes auth state (e.g., from stored tokens).
|
|
149
|
+
*/
|
|
150
|
+
initialize(): Promise<void>
|
|
151
|
+
/**
|
|
152
|
+
* Subscribes to auth state changes.
|
|
153
|
+
*/
|
|
154
|
+
subscribe(callback: (state: AuthState<T>) => void): () => void
|
|
155
|
+
/**
|
|
156
|
+
* Subscribes to auth state changes (alias for subscribe).
|
|
157
|
+
*/
|
|
158
|
+
onAuthChange(callback: (state: AuthState<T>) => void): () => void
|
|
159
|
+
/**
|
|
160
|
+
* Gets the current access token (alias for getAccessToken).
|
|
161
|
+
*/
|
|
162
|
+
getToken?(): string | null
|
|
163
|
+
/**
|
|
164
|
+
* Adds an auth event listener.
|
|
165
|
+
*/
|
|
166
|
+
addEventListener(listener: AuthEventListener): () => void
|
|
167
|
+
/**
|
|
168
|
+
* Destroys the auth client.
|
|
169
|
+
*/
|
|
170
|
+
destroy(): void
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### `AuthPrimitives`
|
|
175
|
+
|
|
176
|
+
Auth primitives return type.
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
interface AuthPrimitives<T = unknown> {
|
|
180
|
+
state: Accessor<AuthState<T>>
|
|
181
|
+
user: Accessor<T | null>
|
|
182
|
+
isAuthenticated: Accessor<boolean>
|
|
183
|
+
isLoading: Accessor<boolean>
|
|
184
|
+
login: AuthClient<T>['login']
|
|
185
|
+
logout: AuthClient<T>['logout']
|
|
186
|
+
register: AuthClient<T>['register']
|
|
187
|
+
refresh: AuthClient<T>['refresh']
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### `AuthState`
|
|
192
|
+
|
|
193
|
+
Reactive authentication state snapshot (initialized, authenticated, user, loading, and error).
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
interface AuthState<T = UserProfile> {
|
|
197
|
+
/**
|
|
198
|
+
* Whether auth state has been initialized.
|
|
199
|
+
*/
|
|
200
|
+
initialized: boolean
|
|
201
|
+
/**
|
|
202
|
+
* Whether the user is authenticated.
|
|
203
|
+
*/
|
|
204
|
+
authenticated: boolean
|
|
205
|
+
/**
|
|
206
|
+
* Current user (if authenticated).
|
|
207
|
+
*/
|
|
208
|
+
user: T | null
|
|
209
|
+
/**
|
|
210
|
+
* Whether an auth operation is in progress.
|
|
211
|
+
*/
|
|
212
|
+
loading: boolean
|
|
213
|
+
/**
|
|
214
|
+
* Last auth error (if any).
|
|
215
|
+
*/
|
|
216
|
+
error: string | null
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
#### `CapacitorAppPrimitives`
|
|
221
|
+
|
|
222
|
+
Capacitor app primitives return type.
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
interface CapacitorAppPrimitives {
|
|
226
|
+
state: Accessor<CapacitorAppState>
|
|
227
|
+
ready: Accessor<boolean>
|
|
228
|
+
initialize: () => Promise<void>
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
#### `CreateAsyncStateReturn`
|
|
233
|
+
|
|
234
|
+
Return type for createAsyncState.
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
interface CreateAsyncStateReturn<T> {
|
|
238
|
+
state: () => T
|
|
239
|
+
setState: (value: T | ((prev: T) => T) | Promise<T | ((prev: T) => T)>) => void
|
|
240
|
+
extendState: (
|
|
241
|
+
partial:
|
|
242
|
+
Partial<T> | ((prev: T) => Partial<T>) | Promise<Partial<T> | ((prev: T) => Partial<T>)>,
|
|
243
|
+
) => void
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
#### `CreateChangePasswordReturn`
|
|
248
|
+
|
|
249
|
+
Return type for createChangePassword primitive.
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
interface CreateChangePasswordReturn {
|
|
253
|
+
state: Accessor<PromiseState<void>>
|
|
254
|
+
changePassword: (oldPassword: string, newPassword: string) => Promise<void>
|
|
255
|
+
reset: () => void
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
#### `CreateFormResult`
|
|
260
|
+
|
|
261
|
+
Result of createForm primitive.
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
interface CreateFormResult<T extends Record<string, unknown>> {
|
|
265
|
+
/** Reactive form state accessor. */
|
|
266
|
+
formState: Accessor<FormState<T>>
|
|
267
|
+
|
|
268
|
+
/** Whether the form is currently valid. */
|
|
269
|
+
isValid: Accessor<boolean>
|
|
270
|
+
|
|
271
|
+
/** Whether any field has been modified. */
|
|
272
|
+
isDirty: Accessor<boolean>
|
|
273
|
+
|
|
274
|
+
/** Whether the form is currently submitting. */
|
|
275
|
+
isSubmitting: Accessor<boolean>
|
|
276
|
+
|
|
277
|
+
/** Current field errors. */
|
|
278
|
+
errors: Accessor<Partial<Record<keyof T, string>>>
|
|
279
|
+
|
|
280
|
+
/** Register a field for form management. */
|
|
281
|
+
register: (name: keyof T, options?: RegisterOptions) => FieldRegistration
|
|
282
|
+
|
|
283
|
+
/** Get the current value of a field. */
|
|
284
|
+
getValue: <K extends keyof T>(name: K) => T[K]
|
|
285
|
+
|
|
286
|
+
/** Set the value of a field. */
|
|
287
|
+
setValue: <K extends keyof T>(name: K, value: T[K]) => void
|
|
288
|
+
|
|
289
|
+
/** Get the error message for a field. */
|
|
290
|
+
getError: (name: keyof T) => string | undefined
|
|
291
|
+
|
|
292
|
+
/** Set an error message for a field. */
|
|
293
|
+
setError: (name: keyof T, error: string | undefined) => void
|
|
294
|
+
|
|
295
|
+
/** Clear all field errors. */
|
|
296
|
+
clearErrors: () => void
|
|
297
|
+
|
|
298
|
+
/** Create a submit handler function. */
|
|
299
|
+
handleSubmit: (
|
|
300
|
+
onSubmit: (values: T) => void | Promise<void>,
|
|
301
|
+
) => (event?: { preventDefault?: () => void }) => Promise<void>
|
|
302
|
+
|
|
303
|
+
/** Reset the form to initial or provided values. */
|
|
304
|
+
reset: (values?: Partial<T>) => void
|
|
305
|
+
|
|
306
|
+
/** Validate all fields. */
|
|
307
|
+
validate: () => Promise<boolean>
|
|
308
|
+
|
|
309
|
+
/** The raw FormController instance for advanced use. */
|
|
310
|
+
controller: FormController<T>
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
#### `CreateLoginReturn`
|
|
315
|
+
|
|
316
|
+
Return type for createLogin primitive.
|
|
317
|
+
|
|
318
|
+
```typescript
|
|
319
|
+
interface CreateLoginReturn<T = unknown> {
|
|
320
|
+
state: Accessor<PromiseState<AuthResult<T>>>
|
|
321
|
+
login: (credentials: LoginCredentials) => Promise<AuthResult<T>>
|
|
322
|
+
reset: () => void
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
#### `CreateOAuthOptions`
|
|
327
|
+
|
|
328
|
+
OAuth configuration options.
|
|
329
|
+
|
|
330
|
+
```typescript
|
|
331
|
+
interface CreateOAuthOptions {
|
|
332
|
+
/** Base URL for the API server (e.g. `https://api.example.com`). */
|
|
333
|
+
baseURL?: string
|
|
334
|
+
/** List of supported OAuth provider names (e.g. `['github', 'google']`). */
|
|
335
|
+
oauthProviders?: string[]
|
|
336
|
+
/** Path prefix for OAuth initiation routes. Defaults to `/oauth`. */
|
|
337
|
+
oauthEndpoint?: string
|
|
338
|
+
/** Path for the OAuth login POST endpoint. Defaults to `/users/log-in/oauth`. */
|
|
339
|
+
loginEndpoint?: string
|
|
340
|
+
/** Called after a successful OAuth login (session established). */
|
|
341
|
+
onSuccess?: () => void
|
|
342
|
+
/** Called with a failure message when the OAuth login fails. */
|
|
343
|
+
onError?: (error: string) => void
|
|
344
|
+
/**
|
|
345
|
+
* Auth client used to establish the session after the code exchange.
|
|
346
|
+
* Overrides context resolution — when omitted, the client is resolved from
|
|
347
|
+
* the surrounding `MoleculeProvider` (tolerated when absent; see the
|
|
348
|
+
* cookie-session fallback documented on
|
|
349
|
+
* {@link CreateOAuthReturn.handleCallback}).
|
|
350
|
+
*/
|
|
351
|
+
authClient?: AuthClient<unknown>
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
#### `CreateOAuthReturn`
|
|
356
|
+
|
|
357
|
+
Return type for createOAuth primitive.
|
|
358
|
+
|
|
359
|
+
```typescript
|
|
360
|
+
interface CreateOAuthReturn {
|
|
361
|
+
/** Accessor for the configured OAuth provider names. */
|
|
362
|
+
providers: Accessor<string[]>
|
|
363
|
+
/** Builds the OAuth initiation URL for a provider. */
|
|
364
|
+
getOAuthUrl: (provider: string) => string
|
|
365
|
+
/** Starts the full-page redirect flow for a provider. */
|
|
366
|
+
redirect: (provider: string) => void
|
|
367
|
+
/**
|
|
368
|
+
* Handles the OAuth callback: exchanges the `code` URL parameter for a
|
|
369
|
+
* session. Invoked automatically at creation (see {@link createOAuth});
|
|
370
|
+
* exposed for callers that need to re-run it manually. No-ops unless
|
|
371
|
+
* running in a browser with a `code` URL parameter and a stashed provider.
|
|
372
|
+
*
|
|
373
|
+
* When an auth client is available (explicit option or context), the
|
|
374
|
+
* session is established locally (`setAccessToken` + `setUser` +
|
|
375
|
+
* `initialize`). When no client is available, the server has already
|
|
376
|
+
* established the httpOnly-cookie session during the exchange, so a
|
|
377
|
+
* user-carrying response still counts as success.
|
|
378
|
+
*/
|
|
379
|
+
handleCallback: () => Promise<void>
|
|
380
|
+
}
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
#### `CreatePasswordResetReturn`
|
|
384
|
+
|
|
385
|
+
Return type for createPasswordReset primitive.
|
|
386
|
+
|
|
387
|
+
```typescript
|
|
388
|
+
interface CreatePasswordResetReturn {
|
|
389
|
+
requestState: Accessor<PromiseState<void>>
|
|
390
|
+
confirmState: Accessor<PromiseState<void>>
|
|
391
|
+
requestReset: (data: PasswordResetRequest) => Promise<void>
|
|
392
|
+
confirmReset: (data: PasswordResetConfirm) => Promise<void>
|
|
393
|
+
reset: () => void
|
|
394
|
+
}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
#### `CreatePromiseReturn`
|
|
398
|
+
|
|
399
|
+
Promise state accessor with actions.
|
|
400
|
+
|
|
401
|
+
```typescript
|
|
402
|
+
interface CreatePromiseReturn<T> {
|
|
403
|
+
state: () => PromiseState<T>
|
|
404
|
+
call: (...args: any[]) => Promise<T>
|
|
405
|
+
cancel: (message?: string) => void
|
|
406
|
+
reset: () => void
|
|
407
|
+
}
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
#### `CreateSignupReturn`
|
|
411
|
+
|
|
412
|
+
Return type for createSignup primitive.
|
|
413
|
+
|
|
414
|
+
```typescript
|
|
415
|
+
interface CreateSignupReturn<T = unknown> {
|
|
416
|
+
state: Accessor<PromiseState<AuthResult<T>>>
|
|
417
|
+
signup: (data: RegisterData) => Promise<AuthResult<T>>
|
|
418
|
+
reset: () => void
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
#### `DevicePrimitives`
|
|
423
|
+
|
|
424
|
+
Device primitives return type.
|
|
425
|
+
|
|
426
|
+
```typescript
|
|
427
|
+
interface DevicePrimitives {
|
|
428
|
+
deviceInfo: DeviceInfo
|
|
429
|
+
screenInfo: ScreenInfo
|
|
430
|
+
hardwareInfo: HardwareInfo
|
|
431
|
+
featureSupport: FeatureSupport
|
|
432
|
+
supports: (feature: keyof FeatureSupport) => boolean
|
|
433
|
+
isOnline: () => boolean
|
|
434
|
+
isStandalone: () => boolean
|
|
435
|
+
language: string
|
|
436
|
+
languages: string[]
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
#### `FormController`
|
|
441
|
+
|
|
442
|
+
Form controller interface.
|
|
443
|
+
|
|
444
|
+
All form providers must implement this interface.
|
|
445
|
+
|
|
446
|
+
```typescript
|
|
447
|
+
interface FormController<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
448
|
+
/**
|
|
449
|
+
* Gets the current form state.
|
|
450
|
+
*/
|
|
451
|
+
getState(): FormState<T>
|
|
452
|
+
/**
|
|
453
|
+
* Gets the value of a specific field.
|
|
454
|
+
*/
|
|
455
|
+
getValue(name: string): unknown
|
|
456
|
+
getValue<K extends keyof T>(name: K): T[K]
|
|
457
|
+
/**
|
|
458
|
+
* Gets all form values.
|
|
459
|
+
*/
|
|
460
|
+
getValues(): T
|
|
461
|
+
/**
|
|
462
|
+
* Sets the value of a specific field.
|
|
463
|
+
*/
|
|
464
|
+
setValue(
|
|
465
|
+
name: string,
|
|
466
|
+
value: unknown,
|
|
467
|
+
options?: {
|
|
468
|
+
shouldValidate?: boolean
|
|
469
|
+
shouldDirty?: boolean
|
|
470
|
+
shouldTouch?: boolean
|
|
471
|
+
},
|
|
472
|
+
): void
|
|
473
|
+
/**
|
|
474
|
+
* Sets multiple values at once.
|
|
475
|
+
*/
|
|
476
|
+
setValues(
|
|
477
|
+
values: Partial<T>,
|
|
478
|
+
options?: {
|
|
479
|
+
shouldValidate?: boolean
|
|
480
|
+
},
|
|
481
|
+
): void
|
|
482
|
+
/**
|
|
483
|
+
* Gets the error for a specific field.
|
|
484
|
+
*/
|
|
485
|
+
getError(name: string): string | undefined
|
|
486
|
+
/**
|
|
487
|
+
* Sets the error for a specific field.
|
|
488
|
+
*/
|
|
489
|
+
setError(name: string, error: string | undefined): void
|
|
490
|
+
/**
|
|
491
|
+
* Clears the error for a specific field.
|
|
492
|
+
*/
|
|
493
|
+
clearError<K extends keyof T>(name: K): void
|
|
494
|
+
/**
|
|
495
|
+
* Clears all errors.
|
|
496
|
+
*/
|
|
497
|
+
clearErrors(): void
|
|
498
|
+
/**
|
|
499
|
+
* Gets the field state for a specific field.
|
|
500
|
+
*/
|
|
501
|
+
getFieldState<K extends keyof T>(name: K): FieldState<T[K]>
|
|
502
|
+
/**
|
|
503
|
+
* Registers a field for form management.
|
|
504
|
+
*/
|
|
505
|
+
register(nameOrOptions: string | RegisterOptions, options?: RegisterOptions): FieldRegistration
|
|
506
|
+
/**
|
|
507
|
+
* Unregisters a field.
|
|
508
|
+
*/
|
|
509
|
+
unregister(name: string): void
|
|
510
|
+
/**
|
|
511
|
+
* Validates a specific field.
|
|
512
|
+
*/
|
|
513
|
+
validateField<K extends keyof T>(name: K): Promise<boolean>
|
|
514
|
+
/**
|
|
515
|
+
* Validates all fields.
|
|
516
|
+
*/
|
|
517
|
+
validate(): Promise<boolean>
|
|
518
|
+
/**
|
|
519
|
+
* Resets the form to initial values.
|
|
520
|
+
*/
|
|
521
|
+
reset(values?: Partial<T>): void
|
|
522
|
+
/**
|
|
523
|
+
* Handles form submission.
|
|
524
|
+
*/
|
|
525
|
+
handleSubmit(
|
|
526
|
+
onSubmit: (values: T) => void | Promise<void>,
|
|
527
|
+
onError?: (errors: Partial<Record<keyof T, string>>) => void,
|
|
528
|
+
): (event?: { preventDefault?: () => void }) => Promise<void>
|
|
529
|
+
/**
|
|
530
|
+
* Sets focus to a field.
|
|
531
|
+
*/
|
|
532
|
+
setFocus(name: keyof T): void
|
|
533
|
+
/**
|
|
534
|
+
* Subscribes to form state changes.
|
|
535
|
+
*/
|
|
536
|
+
subscribe(callback: (state: FormState<T>) => void): () => void
|
|
537
|
+
/**
|
|
538
|
+
* Destroys the form controller.
|
|
539
|
+
*/
|
|
540
|
+
destroy(): void
|
|
541
|
+
}
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
#### `FormOptions`
|
|
545
|
+
|
|
546
|
+
Form creation options.
|
|
547
|
+
|
|
548
|
+
```typescript
|
|
549
|
+
interface FormOptions<T extends Record<string, unknown>> {
|
|
550
|
+
/**
|
|
551
|
+
* Default values.
|
|
552
|
+
*/
|
|
553
|
+
defaultValues?: Partial<T>
|
|
554
|
+
/**
|
|
555
|
+
* Validation mode.
|
|
556
|
+
*/
|
|
557
|
+
mode?: 'onSubmit' | 'onChange' | 'onBlur' | 'all'
|
|
558
|
+
/**
|
|
559
|
+
* Revalidation mode.
|
|
560
|
+
*/
|
|
561
|
+
reValidateMode?: 'onChange' | 'onBlur' | 'onSubmit'
|
|
562
|
+
/**
|
|
563
|
+
* Whether to focus the first error field on submit.
|
|
564
|
+
*/
|
|
565
|
+
shouldFocusError?: boolean
|
|
566
|
+
/**
|
|
567
|
+
* Form-level validation function.
|
|
568
|
+
*/
|
|
569
|
+
validate?: (
|
|
570
|
+
values: T,
|
|
571
|
+
) => Partial<Record<keyof T, string>> | Promise<Partial<Record<keyof T, string>>>
|
|
572
|
+
}
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
#### `HttpClient`
|
|
576
|
+
|
|
577
|
+
HTTP client interface.
|
|
578
|
+
|
|
579
|
+
All HTTP providers must implement this interface.
|
|
580
|
+
|
|
581
|
+
```typescript
|
|
582
|
+
interface HttpClient {
|
|
583
|
+
/**
|
|
584
|
+
* Base URL for all requests.
|
|
585
|
+
*/
|
|
586
|
+
baseURL: string
|
|
587
|
+
/**
|
|
588
|
+
* Default headers for all requests.
|
|
589
|
+
*/
|
|
590
|
+
defaultHeaders: Record<string, string>
|
|
591
|
+
/**
|
|
592
|
+
* Makes a generic HTTP request.
|
|
593
|
+
*/
|
|
594
|
+
request<T = unknown>(config: FullRequestConfig): Promise<HttpResponse<T>>
|
|
595
|
+
/**
|
|
596
|
+
* Makes a GET request.
|
|
597
|
+
*/
|
|
598
|
+
get<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
599
|
+
/**
|
|
600
|
+
* Makes a POST request.
|
|
601
|
+
*/
|
|
602
|
+
post<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
603
|
+
/**
|
|
604
|
+
* Makes a PUT request.
|
|
605
|
+
*/
|
|
606
|
+
put<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
607
|
+
/**
|
|
608
|
+
* Makes a PATCH request.
|
|
609
|
+
*/
|
|
610
|
+
patch<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
611
|
+
/**
|
|
612
|
+
* Makes a DELETE request.
|
|
613
|
+
*/
|
|
614
|
+
delete<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
615
|
+
/**
|
|
616
|
+
* Adds a request interceptor.
|
|
617
|
+
* Returns a function to remove the interceptor.
|
|
618
|
+
*/
|
|
619
|
+
addRequestInterceptor(interceptor: RequestInterceptor): () => void
|
|
620
|
+
/**
|
|
621
|
+
* Adds a response interceptor.
|
|
622
|
+
* Returns a function to remove the interceptor.
|
|
623
|
+
*/
|
|
624
|
+
addResponseInterceptor(interceptor: ResponseInterceptor): () => void
|
|
625
|
+
/**
|
|
626
|
+
* Adds an error interceptor.
|
|
627
|
+
* Returns a function to remove the interceptor.
|
|
628
|
+
*/
|
|
629
|
+
addErrorInterceptor(interceptor: ErrorInterceptor): () => void
|
|
630
|
+
/**
|
|
631
|
+
* Sets the authorization token.
|
|
632
|
+
*/
|
|
633
|
+
setAuthToken(token: string | null): void
|
|
634
|
+
/**
|
|
635
|
+
* Returns the current authorization token, or `null` if not set.
|
|
636
|
+
*/
|
|
637
|
+
getAuthToken(): string | null
|
|
638
|
+
/**
|
|
639
|
+
* Registers a handler for authentication errors (401).
|
|
640
|
+
*
|
|
641
|
+
* @returns An unsubscribe function.
|
|
642
|
+
*/
|
|
643
|
+
onAuthError(handler: () => void): () => void
|
|
644
|
+
}
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
#### `HttpState`
|
|
648
|
+
|
|
649
|
+
State for async HTTP operations.
|
|
650
|
+
|
|
651
|
+
```typescript
|
|
652
|
+
interface HttpState<T> {
|
|
653
|
+
data: T | null
|
|
654
|
+
loading: boolean
|
|
655
|
+
error: Error | null
|
|
656
|
+
}
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
#### `I18nProvider`
|
|
660
|
+
|
|
661
|
+
i18n provider interface.
|
|
662
|
+
|
|
663
|
+
All i18n providers must implement this interface.
|
|
664
|
+
|
|
665
|
+
```typescript
|
|
666
|
+
interface I18nProvider {
|
|
667
|
+
/**
|
|
668
|
+
* Gets the current locale.
|
|
669
|
+
*/
|
|
670
|
+
getLocale(): string
|
|
671
|
+
/**
|
|
672
|
+
* Sets the current locale.
|
|
673
|
+
*
|
|
674
|
+
* **Fleet contract:** every conformant provider (the core simple provider,
|
|
675
|
+
* `@molecule/api-i18n-simple`, `@molecule/app-i18n-i18next`, and
|
|
676
|
+
* `@molecule/app-i18n-react-i18next`) MUST throw `Error('Locale "<code>"
|
|
677
|
+
* not found')` when `locale` is not registered — via the constructor's
|
|
678
|
+
* `initialLocales`/`locales` config, `addLocale()`, or `addTranslations()`
|
|
679
|
+
* (all three register a locale). It must NOT silently degrade to
|
|
680
|
+
* fallback-locale text while `getLocale()` reports the unregistered code —
|
|
681
|
+
* that divergence makes a misconfigured locale switch indistinguishable
|
|
682
|
+
* from a working one until a user notices the wrong language on screen.
|
|
683
|
+
*/
|
|
684
|
+
setLocale(locale: string): Promise<void>
|
|
685
|
+
/**
|
|
686
|
+
* Gets all available locales.
|
|
687
|
+
*/
|
|
688
|
+
getLocales(): LocaleConfig[]
|
|
689
|
+
/**
|
|
690
|
+
* Adds a locale.
|
|
691
|
+
*/
|
|
692
|
+
addLocale(config: LocaleConfig): void
|
|
693
|
+
/**
|
|
694
|
+
* Removes a locale by code, notifying subscribers so language pickers
|
|
695
|
+
* built on `onLocaleChange` re-render their list. If the removed locale
|
|
696
|
+
* is currently active, the caller is responsible for switching to a
|
|
697
|
+
* fallback (e.g. `'en'`) BEFORE calling this — the provider will not
|
|
698
|
+
* auto-fall-back on its own.
|
|
699
|
+
*
|
|
700
|
+
* Returns `true` if the locale was registered and removed, `false`
|
|
701
|
+
* otherwise.
|
|
702
|
+
*/
|
|
703
|
+
removeLocale(code: string): boolean
|
|
704
|
+
/**
|
|
705
|
+
* Adds translations to a locale. Auto-creates the locale if it doesn't exist.
|
|
706
|
+
*
|
|
707
|
+
* **Fleet contract:** merges are DEEP, not a shallow spread — registering
|
|
708
|
+
* two calls (e.g. two modules) that share a top-level namespace key merges
|
|
709
|
+
* their subtrees instead of the second call clobbering the first's nested
|
|
710
|
+
* translations wholesale. `@molecule/api-i18n-simple` implements the same
|
|
711
|
+
* contract on the API side.
|
|
712
|
+
*/
|
|
713
|
+
addTranslations(locale: string, translations: Translations, namespace?: string): void
|
|
714
|
+
/**
|
|
715
|
+
* Translates a key with optional interpolation values and pluralization.
|
|
716
|
+
*
|
|
717
|
+
* **Fleet plural contract (matches i18next's own key resolution order):**
|
|
718
|
+
* when `options.count` is provided, the plural-suffixed key
|
|
719
|
+
* (`` `${key}_${pluralForm}` ``, e.g. `item_one`/`item_few`/…, falling back
|
|
720
|
+
* to `` `${key}_other` ``) is looked up FIRST and wins over the base `key`
|
|
721
|
+
* if BOTH are registered. Only when no plural-suffixed key exists at all
|
|
722
|
+
* does resolution fall back to the base key. A catalog that ships both
|
|
723
|
+
* `item` and `item_one`/`item_other` therefore pluralizes identically
|
|
724
|
+
* whichever provider is bonded.
|
|
725
|
+
*
|
|
726
|
+
* @returns The translated string, or the default value / key if not found.
|
|
727
|
+
*/
|
|
728
|
+
t(
|
|
729
|
+
key: string,
|
|
730
|
+
values?: InterpolationValues,
|
|
731
|
+
options?: {
|
|
732
|
+
defaultValue?: string
|
|
733
|
+
count?: number
|
|
734
|
+
},
|
|
735
|
+
): string
|
|
736
|
+
/**
|
|
737
|
+
* Checks if a translation key exists.
|
|
738
|
+
*
|
|
739
|
+
* **Fleet contract:** follows the SAME locale-resolution chain as `t()` —
|
|
740
|
+
* the active locale, then the English fallback — so `exists(key) === true`
|
|
741
|
+
* whenever `t(key)` would render real translated text (not the raw key or
|
|
742
|
+
* an inline `defaultValue`). Do not narrow this to "only the active
|
|
743
|
+
* locale's own catalog"; that made `exists()` return `false` for keys `t()`
|
|
744
|
+
* happily rendered via the English fallback, and the answer differed by
|
|
745
|
+
* provider.
|
|
746
|
+
*
|
|
747
|
+
* @returns `true` if the key has a translation.
|
|
748
|
+
*/
|
|
749
|
+
exists(key: string): boolean
|
|
750
|
+
/**
|
|
751
|
+
* Formats a number according to the current locale.
|
|
752
|
+
*
|
|
753
|
+
* @returns The locale-formatted number string.
|
|
754
|
+
*/
|
|
755
|
+
formatNumber(value: number, options?: NumberFormatOptions): string
|
|
756
|
+
/**
|
|
757
|
+
* Formats a date according to the current locale.
|
|
758
|
+
*
|
|
759
|
+
* @returns The locale-formatted date string.
|
|
760
|
+
*/
|
|
761
|
+
formatDate(value: Date | number | string, options?: DateFormatOptions): string
|
|
762
|
+
/**
|
|
763
|
+
* Formats a relative time (e.g. "2 hours ago").
|
|
764
|
+
*
|
|
765
|
+
* @returns The locale-formatted relative time string.
|
|
766
|
+
*/
|
|
767
|
+
formatRelativeTime(
|
|
768
|
+
value: Date | number,
|
|
769
|
+
options?: {
|
|
770
|
+
unit?: Intl.RelativeTimeFormatUnit
|
|
771
|
+
},
|
|
772
|
+
): string
|
|
773
|
+
/**
|
|
774
|
+
* Formats a list (e.g. "A, B, and C").
|
|
775
|
+
*
|
|
776
|
+
* @returns The locale-formatted list string.
|
|
777
|
+
*/
|
|
778
|
+
formatList(
|
|
779
|
+
values: string[],
|
|
780
|
+
options?: {
|
|
781
|
+
type?: 'conjunction' | 'disjunction' | 'unit'
|
|
782
|
+
},
|
|
783
|
+
): string
|
|
784
|
+
/**
|
|
785
|
+
* Subscribes to locale changes.
|
|
786
|
+
*
|
|
787
|
+
* @returns An unsubscribe function.
|
|
788
|
+
*/
|
|
789
|
+
onLocaleChange(listener: (locale: string) => void): () => void
|
|
790
|
+
/**
|
|
791
|
+
* Gets the text direction for the current locale.
|
|
792
|
+
*
|
|
793
|
+
* @returns `'ltr'` or `'rtl'`.
|
|
794
|
+
*/
|
|
795
|
+
getDirection(): 'ltr' | 'rtl'
|
|
796
|
+
/**
|
|
797
|
+
* Checks if a translation key exists (alias for exists).
|
|
798
|
+
*/
|
|
799
|
+
hasKey?(key: string): boolean
|
|
800
|
+
/**
|
|
801
|
+
* Checks if the provider is ready.
|
|
802
|
+
*/
|
|
803
|
+
isReady?(): boolean
|
|
804
|
+
/**
|
|
805
|
+
* Registers a callback for when the provider is ready.
|
|
806
|
+
*/
|
|
807
|
+
onReady?(callback: () => void): () => void
|
|
808
|
+
/**
|
|
809
|
+
* Registers a lazily-loaded content module for automatic reload on locale changes.
|
|
810
|
+
* All registered content is reloaded during `setLocale()` before listeners fire,
|
|
811
|
+
* ensuring content is available on the first re-render with no flash.
|
|
812
|
+
*
|
|
813
|
+
* Idempotent: registering the same module name twice is a no-op.
|
|
814
|
+
*/
|
|
815
|
+
registerContent?(module: string, loader: (locale: string) => Promise<void>): void
|
|
816
|
+
}
|
|
817
|
+
```
|
|
818
|
+
|
|
819
|
+
#### `Logger`
|
|
820
|
+
|
|
821
|
+
Logger instance with leveled logging methods, child logger creation,
|
|
822
|
+
and transport management.
|
|
823
|
+
|
|
824
|
+
```typescript
|
|
825
|
+
interface Logger {
|
|
826
|
+
/**
|
|
827
|
+
* Logs a trace message.
|
|
828
|
+
*/
|
|
829
|
+
trace(message: string, ...args: unknown[]): void
|
|
830
|
+
/**
|
|
831
|
+
* Logs a debug message.
|
|
832
|
+
*/
|
|
833
|
+
debug(message: string, ...args: unknown[]): void
|
|
834
|
+
/**
|
|
835
|
+
* Logs an info message.
|
|
836
|
+
*/
|
|
837
|
+
info(message: string, ...args: unknown[]): void
|
|
838
|
+
/**
|
|
839
|
+
* Logs a warning message.
|
|
840
|
+
*/
|
|
841
|
+
warn(message: string, ...args: unknown[]): void
|
|
842
|
+
/**
|
|
843
|
+
* Logs an error message.
|
|
844
|
+
*/
|
|
845
|
+
error(message: string | Error, ...args: unknown[]): void
|
|
846
|
+
/**
|
|
847
|
+
* Sets the log level.
|
|
848
|
+
*/
|
|
849
|
+
setLevel(level: LogLevel): void
|
|
850
|
+
/**
|
|
851
|
+
* Gets the current log level.
|
|
852
|
+
*/
|
|
853
|
+
getLevel(): LogLevel
|
|
854
|
+
/**
|
|
855
|
+
* Creates a child logger with a namespace.
|
|
856
|
+
*/
|
|
857
|
+
child(name: string, context?: Record<string, unknown>): Logger
|
|
858
|
+
/**
|
|
859
|
+
* Adds additional context to the logger.
|
|
860
|
+
*/
|
|
861
|
+
withContext(context: Record<string, unknown>): Logger
|
|
862
|
+
/**
|
|
863
|
+
* Adds a transport.
|
|
864
|
+
*/
|
|
865
|
+
addTransport(transport: LogTransport): () => void
|
|
866
|
+
/**
|
|
867
|
+
* Removes a transport.
|
|
868
|
+
*/
|
|
869
|
+
removeTransport(transport: LogTransport): void
|
|
870
|
+
}
|
|
871
|
+
```
|
|
872
|
+
|
|
873
|
+
#### `LoggerProvider`
|
|
874
|
+
|
|
875
|
+
Logger provider interface that all logger bond packages must implement.
|
|
876
|
+
Creates and manages logger instances and global log configuration.
|
|
877
|
+
|
|
878
|
+
```typescript
|
|
879
|
+
interface LoggerProvider {
|
|
880
|
+
/**
|
|
881
|
+
* Gets a logger by name, or the root logger if no name given.
|
|
882
|
+
*/
|
|
883
|
+
getLogger(name?: string): Logger
|
|
884
|
+
/**
|
|
885
|
+
* Creates a named logger.
|
|
886
|
+
*/
|
|
887
|
+
createLogger(nameOrConfig: string | LoggerConfig, config?: LoggerConfig): Logger
|
|
888
|
+
/**
|
|
889
|
+
* Sets the global log level.
|
|
890
|
+
*/
|
|
891
|
+
setLevel(level: LogLevel): void
|
|
892
|
+
/**
|
|
893
|
+
* Gets the global log level.
|
|
894
|
+
*/
|
|
895
|
+
getLevel(): LogLevel
|
|
896
|
+
/**
|
|
897
|
+
* Adds a global transport.
|
|
898
|
+
*/
|
|
899
|
+
addTransport(transport: LogTransport): () => void
|
|
900
|
+
/**
|
|
901
|
+
* Enables logging.
|
|
902
|
+
*/
|
|
903
|
+
enable(): void
|
|
904
|
+
/**
|
|
905
|
+
* Disables logging.
|
|
906
|
+
*/
|
|
907
|
+
disable(): void
|
|
908
|
+
/**
|
|
909
|
+
* Checks if logging is enabled.
|
|
910
|
+
*
|
|
911
|
+
* @returns `true` if logging is currently enabled.
|
|
912
|
+
*/
|
|
913
|
+
isEnabled(): boolean
|
|
914
|
+
}
|
|
915
|
+
```
|
|
916
|
+
|
|
917
|
+
#### `MoleculeConfig`
|
|
918
|
+
|
|
919
|
+
Configuration for molecule Solid context.
|
|
920
|
+
|
|
921
|
+
```typescript
|
|
922
|
+
interface MoleculeConfig {
|
|
923
|
+
state?: StateProvider
|
|
924
|
+
auth?: AuthClient<unknown>
|
|
925
|
+
theme?: ThemeProvider
|
|
926
|
+
router?: Router
|
|
927
|
+
i18n?: I18nProvider
|
|
928
|
+
http?: HttpClient
|
|
929
|
+
storage?: StorageProvider
|
|
930
|
+
logger?: LoggerProvider
|
|
931
|
+
}
|
|
932
|
+
```
|
|
933
|
+
|
|
934
|
+
#### `MoleculeStore`
|
|
935
|
+
|
|
936
|
+
Reactive state container with getState, setState, subscribe, and destroy.
|
|
937
|
+
|
|
938
|
+
All state management providers must implement this interface.
|
|
939
|
+
|
|
940
|
+
```typescript
|
|
941
|
+
interface Store<T> {
|
|
942
|
+
/**
|
|
943
|
+
* Gets the current state.
|
|
944
|
+
*/
|
|
945
|
+
getState(): T
|
|
946
|
+
/**
|
|
947
|
+
* Sets the state (partial or via updater function).
|
|
948
|
+
*/
|
|
949
|
+
setState(partial: Partial<T> | ((state: T) => Partial<T>)): void
|
|
950
|
+
/**
|
|
951
|
+
* Subscribes to state changes.
|
|
952
|
+
* Returns an unsubscribe function.
|
|
953
|
+
*/
|
|
954
|
+
subscribe(listener: StateListener<T>): () => void
|
|
955
|
+
/**
|
|
956
|
+
* Destroys the store and cleans up subscriptions.
|
|
957
|
+
*/
|
|
958
|
+
destroy(): void
|
|
959
|
+
}
|
|
960
|
+
```
|
|
961
|
+
|
|
962
|
+
#### `PlatformPrimitives`
|
|
963
|
+
|
|
964
|
+
Platform primitives return type.
|
|
965
|
+
|
|
966
|
+
```typescript
|
|
967
|
+
interface PlatformPrimitives {
|
|
968
|
+
platform: Platform
|
|
969
|
+
isNative: boolean
|
|
970
|
+
isMobile: boolean
|
|
971
|
+
isDesktop: boolean
|
|
972
|
+
isWeb: boolean
|
|
973
|
+
isDevelopment: boolean
|
|
974
|
+
isProduction: boolean
|
|
975
|
+
isPlatform: (...platforms: Platform[]) => boolean
|
|
976
|
+
}
|
|
977
|
+
```
|
|
978
|
+
|
|
979
|
+
#### `PushPrimitives`
|
|
980
|
+
|
|
981
|
+
Push primitives return type.
|
|
982
|
+
|
|
983
|
+
```typescript
|
|
984
|
+
interface PushPrimitives {
|
|
985
|
+
permission: Accessor<PermissionStatus | null>
|
|
986
|
+
token: Accessor<PushToken | null>
|
|
987
|
+
checkPermission: () => Promise<PermissionStatus>
|
|
988
|
+
requestPermission: () => Promise<PermissionStatus>
|
|
989
|
+
register: (options?: PushRegisterOptions) => Promise<PushToken>
|
|
990
|
+
unregister: () => Promise<void>
|
|
991
|
+
onNotificationReceived: (listener: NotificationReceivedListener) => () => void
|
|
992
|
+
onNotificationAction: (listener: NotificationActionListener) => () => void
|
|
993
|
+
onTokenChange: (listener: TokenChangeListener) => () => void
|
|
994
|
+
setBadge: (count: number) => Promise<void>
|
|
995
|
+
clearBadge: () => Promise<void>
|
|
996
|
+
}
|
|
997
|
+
```
|
|
998
|
+
|
|
999
|
+
#### `RouteLocation`
|
|
1000
|
+
|
|
1001
|
+
Current URL decomposed into pathname, search string, hash, navigation state, and unique key.
|
|
1002
|
+
|
|
1003
|
+
```typescript
|
|
1004
|
+
interface RouteLocation {
|
|
1005
|
+
/**
|
|
1006
|
+
* Current pathname.
|
|
1007
|
+
*/
|
|
1008
|
+
pathname: string
|
|
1009
|
+
/**
|
|
1010
|
+
* Query string (including leading ?).
|
|
1011
|
+
*/
|
|
1012
|
+
search: string
|
|
1013
|
+
/**
|
|
1014
|
+
* Hash (including leading #).
|
|
1015
|
+
*/
|
|
1016
|
+
hash: string
|
|
1017
|
+
/**
|
|
1018
|
+
* State data passed with navigation.
|
|
1019
|
+
*/
|
|
1020
|
+
state?: unknown
|
|
1021
|
+
/**
|
|
1022
|
+
* Unique key for this location.
|
|
1023
|
+
*/
|
|
1024
|
+
key?: string
|
|
1025
|
+
}
|
|
1026
|
+
```
|
|
1027
|
+
|
|
1028
|
+
#### `Router`
|
|
1029
|
+
|
|
1030
|
+
Client-side router providing navigation, guards, route matching, and history control.
|
|
1031
|
+
|
|
1032
|
+
All routing providers must implement this interface.
|
|
1033
|
+
|
|
1034
|
+
```typescript
|
|
1035
|
+
interface Router {
|
|
1036
|
+
/**
|
|
1037
|
+
* Returns the current route location (pathname, search, hash, state).
|
|
1038
|
+
*/
|
|
1039
|
+
getLocation(): RouteLocation
|
|
1040
|
+
/**
|
|
1041
|
+
* Gets the current route params.
|
|
1042
|
+
*/
|
|
1043
|
+
getParams<T extends RouteParams = RouteParams>(): T
|
|
1044
|
+
/**
|
|
1045
|
+
* Gets the current query params.
|
|
1046
|
+
*/
|
|
1047
|
+
getQuery(): QueryParams
|
|
1048
|
+
/**
|
|
1049
|
+
* Gets a specific query parameter.
|
|
1050
|
+
*/
|
|
1051
|
+
getQueryParam(key: string): string | undefined
|
|
1052
|
+
/**
|
|
1053
|
+
* Gets the current hash.
|
|
1054
|
+
*/
|
|
1055
|
+
getHash(): string
|
|
1056
|
+
/**
|
|
1057
|
+
* Navigates to a path.
|
|
1058
|
+
*/
|
|
1059
|
+
navigate(path: string, options?: NavigateOptions): void
|
|
1060
|
+
/**
|
|
1061
|
+
* Navigates to a named route.
|
|
1062
|
+
*/
|
|
1063
|
+
navigateTo(
|
|
1064
|
+
name: string,
|
|
1065
|
+
params?: RouteParams,
|
|
1066
|
+
query?: QueryParams,
|
|
1067
|
+
options?: NavigateOptions,
|
|
1068
|
+
): void
|
|
1069
|
+
/**
|
|
1070
|
+
* Goes back in history.
|
|
1071
|
+
*/
|
|
1072
|
+
back(): void
|
|
1073
|
+
/**
|
|
1074
|
+
* Goes forward in history.
|
|
1075
|
+
*/
|
|
1076
|
+
forward(): void
|
|
1077
|
+
/**
|
|
1078
|
+
* Goes to a specific point in history.
|
|
1079
|
+
*/
|
|
1080
|
+
go(delta: number): void
|
|
1081
|
+
/**
|
|
1082
|
+
* Updates the current query params.
|
|
1083
|
+
*/
|
|
1084
|
+
setQuery(params: QueryParams, options?: NavigateOptions): void
|
|
1085
|
+
/**
|
|
1086
|
+
* Updates a specific query parameter.
|
|
1087
|
+
*/
|
|
1088
|
+
setQueryParam(key: string, value: string | undefined, options?: NavigateOptions): void
|
|
1089
|
+
/**
|
|
1090
|
+
* Updates the current hash.
|
|
1091
|
+
*/
|
|
1092
|
+
setHash(hash: string, options?: NavigateOptions): void
|
|
1093
|
+
/**
|
|
1094
|
+
* Checks if a path matches the current location.
|
|
1095
|
+
*
|
|
1096
|
+
* @returns `true` if the path matches the current route.
|
|
1097
|
+
*/
|
|
1098
|
+
isActive(path: string, exact?: boolean): boolean
|
|
1099
|
+
/**
|
|
1100
|
+
* Matches a path pattern against a pathname.
|
|
1101
|
+
*/
|
|
1102
|
+
matchPath<Params extends RouteParams = RouteParams>(
|
|
1103
|
+
pattern: string,
|
|
1104
|
+
pathname: string,
|
|
1105
|
+
): RouteMatch<Params> | null
|
|
1106
|
+
/**
|
|
1107
|
+
* Generates a URL from a named route.
|
|
1108
|
+
*/
|
|
1109
|
+
generatePath(name: string, params?: RouteParams, query?: QueryParams): string
|
|
1110
|
+
/**
|
|
1111
|
+
* Subscribes to route changes.
|
|
1112
|
+
*/
|
|
1113
|
+
subscribe(listener: RouteChangeListener): () => void
|
|
1114
|
+
/**
|
|
1115
|
+
* Adds a navigation guard.
|
|
1116
|
+
*/
|
|
1117
|
+
addGuard(guard: NavigationGuard): () => void
|
|
1118
|
+
/**
|
|
1119
|
+
* Registers route definitions.
|
|
1120
|
+
*/
|
|
1121
|
+
registerRoutes(routes: RouteDefinition[]): void
|
|
1122
|
+
/**
|
|
1123
|
+
* Gets all registered routes.
|
|
1124
|
+
*/
|
|
1125
|
+
getRoutes(): RouteDefinition[]
|
|
1126
|
+
/**
|
|
1127
|
+
* Destroys the router.
|
|
1128
|
+
*/
|
|
1129
|
+
destroy(): void
|
|
1130
|
+
}
|
|
1131
|
+
```
|
|
1132
|
+
|
|
1133
|
+
#### `RouterPrimitives`
|
|
1134
|
+
|
|
1135
|
+
Router primitives return type.
|
|
1136
|
+
|
|
1137
|
+
```typescript
|
|
1138
|
+
interface RouterPrimitives {
|
|
1139
|
+
location: Accessor<RouteLocation>
|
|
1140
|
+
params: Accessor<RouteParams>
|
|
1141
|
+
query: Accessor<QueryParams>
|
|
1142
|
+
navigate: Router['navigate']
|
|
1143
|
+
navigateTo: Router['navigateTo']
|
|
1144
|
+
back: Router['back']
|
|
1145
|
+
forward: Router['forward']
|
|
1146
|
+
isActive: Router['isActive']
|
|
1147
|
+
}
|
|
1148
|
+
```
|
|
1149
|
+
|
|
1150
|
+
#### `StateProvider`
|
|
1151
|
+
|
|
1152
|
+
State provider interface that all state management bond packages
|
|
1153
|
+
must implement. Provides the store creation factory.
|
|
1154
|
+
|
|
1155
|
+
```typescript
|
|
1156
|
+
interface StateProvider {
|
|
1157
|
+
/**
|
|
1158
|
+
* Creates a new store.
|
|
1159
|
+
*/
|
|
1160
|
+
createStore<T>(config: StoreConfig<T>): Store<T>
|
|
1161
|
+
}
|
|
1162
|
+
```
|
|
1163
|
+
|
|
1164
|
+
#### `StorageProvider`
|
|
1165
|
+
|
|
1166
|
+
Storage provider interface.
|
|
1167
|
+
|
|
1168
|
+
All storage providers must implement this interface.
|
|
1169
|
+
|
|
1170
|
+
```typescript
|
|
1171
|
+
interface StorageProvider {
|
|
1172
|
+
/**
|
|
1173
|
+
* Gets a value from storage.
|
|
1174
|
+
*/
|
|
1175
|
+
get<T = unknown>(key: string): Promise<T | null>
|
|
1176
|
+
/**
|
|
1177
|
+
* Sets a value in storage.
|
|
1178
|
+
*/
|
|
1179
|
+
set<T = unknown>(key: string, value: T): Promise<void>
|
|
1180
|
+
/**
|
|
1181
|
+
* Removes a value from storage.
|
|
1182
|
+
*/
|
|
1183
|
+
remove(key: string): Promise<void>
|
|
1184
|
+
/**
|
|
1185
|
+
* Clears all values from storage.
|
|
1186
|
+
*/
|
|
1187
|
+
clear(): Promise<void>
|
|
1188
|
+
/**
|
|
1189
|
+
* Gets all keys in storage.
|
|
1190
|
+
*/
|
|
1191
|
+
keys(): Promise<string[]>
|
|
1192
|
+
/**
|
|
1193
|
+
* Gets multiple values from storage.
|
|
1194
|
+
*/
|
|
1195
|
+
getMany?<T = unknown>(keys: string[]): Promise<Map<string, T | null>>
|
|
1196
|
+
/**
|
|
1197
|
+
* Sets multiple values in storage.
|
|
1198
|
+
*/
|
|
1199
|
+
setMany?<T = unknown>(entries: Array<[string, T]>): Promise<void>
|
|
1200
|
+
/**
|
|
1201
|
+
* Removes multiple values from storage.
|
|
1202
|
+
*/
|
|
1203
|
+
removeMany?(keys: string[]): Promise<void>
|
|
1204
|
+
}
|
|
1205
|
+
```
|
|
1206
|
+
|
|
1207
|
+
#### `StorageValueState`
|
|
1208
|
+
|
|
1209
|
+
State for async storage values.
|
|
1210
|
+
|
|
1211
|
+
```typescript
|
|
1212
|
+
interface StorageValueState<T> {
|
|
1213
|
+
value: T | undefined
|
|
1214
|
+
loading: boolean
|
|
1215
|
+
error: Error | null
|
|
1216
|
+
}
|
|
1217
|
+
```
|
|
1218
|
+
|
|
1219
|
+
#### `StoreConfig`
|
|
1220
|
+
|
|
1221
|
+
Configuration for creating a store (initial state, optional name, and middleware chain).
|
|
1222
|
+
|
|
1223
|
+
```typescript
|
|
1224
|
+
interface StoreConfig<T> {
|
|
1225
|
+
/**
|
|
1226
|
+
* Initial state value.
|
|
1227
|
+
*/
|
|
1228
|
+
initialState: T
|
|
1229
|
+
/**
|
|
1230
|
+
* Optional name for debugging.
|
|
1231
|
+
*/
|
|
1232
|
+
name?: string
|
|
1233
|
+
/**
|
|
1234
|
+
* Optional middleware functions.
|
|
1235
|
+
*/
|
|
1236
|
+
middleware?: StoreMiddleware<T>[]
|
|
1237
|
+
}
|
|
1238
|
+
```
|
|
1239
|
+
|
|
1240
|
+
#### `Theme`
|
|
1241
|
+
|
|
1242
|
+
Complete theme definition.
|
|
1243
|
+
|
|
1244
|
+
```typescript
|
|
1245
|
+
interface Theme {
|
|
1246
|
+
name: string
|
|
1247
|
+
mode: 'light' | 'dark'
|
|
1248
|
+
colors: ThemeColors
|
|
1249
|
+
breakpoints: ThemeBreakpoints
|
|
1250
|
+
spacing: ThemeSpacing
|
|
1251
|
+
typography: ThemeTypography
|
|
1252
|
+
borderRadius: ThemeBorderRadius
|
|
1253
|
+
shadows: ThemeShadows
|
|
1254
|
+
transitions: ThemeTransitions
|
|
1255
|
+
zIndex: ThemeZIndex
|
|
1256
|
+
}
|
|
1257
|
+
```
|
|
1258
|
+
|
|
1259
|
+
#### `ThemePrimitives`
|
|
1260
|
+
|
|
1261
|
+
Theme primitives return type.
|
|
1262
|
+
|
|
1263
|
+
```typescript
|
|
1264
|
+
interface ThemePrimitives {
|
|
1265
|
+
theme: Accessor<Theme>
|
|
1266
|
+
themeName: Accessor<string>
|
|
1267
|
+
mode: Accessor<'light' | 'dark'>
|
|
1268
|
+
setTheme: (name: string) => void
|
|
1269
|
+
toggleTheme: () => void
|
|
1270
|
+
}
|
|
1271
|
+
```
|
|
1272
|
+
|
|
1273
|
+
#### `ThemeProvider`
|
|
1274
|
+
|
|
1275
|
+
Manages theme state including the active theme, mode toggling,
|
|
1276
|
+
and change subscriptions.
|
|
1277
|
+
|
|
1278
|
+
```typescript
|
|
1279
|
+
interface ThemeProvider {
|
|
1280
|
+
/**
|
|
1281
|
+
* Returns the currently active theme.
|
|
1282
|
+
*/
|
|
1283
|
+
getTheme(): Theme
|
|
1284
|
+
/**
|
|
1285
|
+
* Sets the active theme by reference or by name.
|
|
1286
|
+
*
|
|
1287
|
+
* @param theme - A `Theme` object or a theme name string to activate.
|
|
1288
|
+
*/
|
|
1289
|
+
setTheme(theme: Theme | string): void
|
|
1290
|
+
/**
|
|
1291
|
+
* Toggles between light and dark mode for the active theme.
|
|
1292
|
+
*/
|
|
1293
|
+
toggleMode(): void
|
|
1294
|
+
/**
|
|
1295
|
+
* Subscribes to theme changes. The callback fires whenever
|
|
1296
|
+
* `setTheme()` or `toggleMode()` is called.
|
|
1297
|
+
*
|
|
1298
|
+
* @param callback - Invoked with the new theme after each change.
|
|
1299
|
+
* @returns An unsubscribe function.
|
|
1300
|
+
*/
|
|
1301
|
+
subscribe(callback: (theme: Theme) => void): () => void
|
|
1302
|
+
/**
|
|
1303
|
+
* Returns all registered themes. Optional — not all providers
|
|
1304
|
+
* support multiple themes.
|
|
1305
|
+
*/
|
|
1306
|
+
getThemes?(): Theme[]
|
|
1307
|
+
}
|
|
1308
|
+
```
|
|
1309
|
+
|
|
1310
|
+
#### `VersionPrimitives`
|
|
1311
|
+
|
|
1312
|
+
Version primitives return type.
|
|
1313
|
+
|
|
1314
|
+
```typescript
|
|
1315
|
+
interface VersionPrimitives {
|
|
1316
|
+
state: Accessor<VersionState>
|
|
1317
|
+
isUpdateAvailable: Accessor<boolean>
|
|
1318
|
+
isChecking: Accessor<boolean>
|
|
1319
|
+
isServiceWorkerWaiting: Accessor<boolean>
|
|
1320
|
+
newVersion: Accessor<string | undefined>
|
|
1321
|
+
checkForUpdates: () => Promise<boolean>
|
|
1322
|
+
applyUpdate: (options?: { force?: boolean }) => void
|
|
1323
|
+
dismissUpdate: () => void
|
|
1324
|
+
startPeriodicChecks: (options?: UpdateCheckOptions) => void
|
|
1325
|
+
stopPeriodicChecks: () => void
|
|
1326
|
+
}
|
|
1327
|
+
```
|
|
1328
|
+
|
|
1329
|
+
### Types
|
|
1330
|
+
|
|
1331
|
+
#### `Accessor`
|
|
1332
|
+
|
|
1333
|
+
```typescript
|
|
1334
|
+
type Accessor<T> = () => T
|
|
1335
|
+
```
|
|
1336
|
+
|
|
1337
|
+
#### `QueryParams`
|
|
1338
|
+
|
|
1339
|
+
URL query string parameter map (single values or arrays for repeated keys).
|
|
1340
|
+
|
|
1341
|
+
```typescript
|
|
1342
|
+
type QueryParams = Record<string, string | string[] | undefined>
|
|
1343
|
+
```
|
|
1344
|
+
|
|
1345
|
+
#### `RouteParams`
|
|
1346
|
+
|
|
1347
|
+
URL path parameter key-value map extracted from dynamic route segments (e.g. `{ id: '123' }`).
|
|
1348
|
+
|
|
1349
|
+
```typescript
|
|
1350
|
+
type RouteParams = Record<string, string>
|
|
1351
|
+
```
|
|
1352
|
+
|
|
1353
|
+
#### `Setter`
|
|
1354
|
+
|
|
1355
|
+
```typescript
|
|
1356
|
+
type Setter<in out T> = {
|
|
1357
|
+
<U extends T>(
|
|
1358
|
+
...args: undefined extends T ? [] : [value: Exclude<U, Function> | ((prev: T) => U)]
|
|
1359
|
+
): undefined extends T ? undefined : U
|
|
1360
|
+
<U extends T>(value: (prev: T) => U): U
|
|
1361
|
+
<U extends T>(value: Exclude<U, Function>): U
|
|
1362
|
+
<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)): U
|
|
1363
|
+
}
|
|
1364
|
+
```
|
|
1365
|
+
|
|
1366
|
+
### Functions
|
|
1367
|
+
|
|
1368
|
+
#### `applyThemeToDocument()`
|
|
1369
|
+
|
|
1370
|
+
Apply theme CSS variables to document.
|
|
1371
|
+
|
|
1372
|
+
```typescript
|
|
1373
|
+
function applyThemeToDocument(): void
|
|
1374
|
+
```
|
|
1375
|
+
|
|
1376
|
+
#### `createAsyncState(initialState)`
|
|
1377
|
+
|
|
1378
|
+
Primitive like createSignal but accepts Promises and supports partial state extension.
|
|
1379
|
+
|
|
1380
|
+
```typescript
|
|
1381
|
+
function createAsyncState(initialState: T): CreateAsyncStateReturn<T>
|
|
1382
|
+
```
|
|
1383
|
+
|
|
1384
|
+
- `initialState` — Initial state value
|
|
1385
|
+
|
|
1386
|
+
**Returns:** The created instance.
|
|
1387
|
+
|
|
1388
|
+
#### `createAuth()`
|
|
1389
|
+
|
|
1390
|
+
Create auth primitives for authentication state and actions.
|
|
1391
|
+
|
|
1392
|
+
```typescript
|
|
1393
|
+
function createAuth(): AuthPrimitives<T>
|
|
1394
|
+
```
|
|
1395
|
+
|
|
1396
|
+
**Returns:** Auth primitives object
|
|
1397
|
+
|
|
1398
|
+
#### `createAuthFromClient(client)`
|
|
1399
|
+
|
|
1400
|
+
Create auth primitives from a specific client.
|
|
1401
|
+
|
|
1402
|
+
```typescript
|
|
1403
|
+
function createAuthFromClient(client: AuthClient<T>): AuthPrimitives<T>
|
|
1404
|
+
```
|
|
1405
|
+
|
|
1406
|
+
- `client` — Auth client
|
|
1407
|
+
|
|
1408
|
+
**Returns:** Auth primitives
|
|
1409
|
+
|
|
1410
|
+
#### `createAuthGuard(redirectTo)`
|
|
1411
|
+
|
|
1412
|
+
Create a guard primitive that redirects unauthenticated users.
|
|
1413
|
+
|
|
1414
|
+
```typescript
|
|
1415
|
+
function createAuthGuard(redirectTo: string): Accessor<boolean>
|
|
1416
|
+
```
|
|
1417
|
+
|
|
1418
|
+
- `redirectTo` — Path to redirect to
|
|
1419
|
+
|
|
1420
|
+
**Returns:** Accessor indicating if user is allowed
|
|
1421
|
+
|
|
1422
|
+
#### `createAuthHelpers()`
|
|
1423
|
+
|
|
1424
|
+
Creates a auth helpers.
|
|
1425
|
+
|
|
1426
|
+
```typescript
|
|
1427
|
+
function createAuthHelpers(): {
|
|
1428
|
+
login: (credentials: LoginCredentials) => Promise<AuthResult<T>>
|
|
1429
|
+
logout: () => Promise<void>
|
|
1430
|
+
register: (data: RegisterData) => Promise<AuthResult<T>>
|
|
1431
|
+
refresh: () => Promise<AuthResult<T>>
|
|
1432
|
+
getUser: () => T | null
|
|
1433
|
+
getToken: () => string | null
|
|
1434
|
+
isAuthenticated: () => boolean
|
|
1435
|
+
}
|
|
1436
|
+
```
|
|
1437
|
+
|
|
1438
|
+
**Returns:** The created result.
|
|
1439
|
+
|
|
1440
|
+
#### `createCapacitorApp(options)`
|
|
1441
|
+
|
|
1442
|
+
Create Capacitor app primitives for native app initialization.
|
|
1443
|
+
|
|
1444
|
+
Wraps the core `createCapacitorApp` coordinator with Solid signals,
|
|
1445
|
+
automatically initializing and cleaning up on disposal.
|
|
1446
|
+
|
|
1447
|
+
```typescript
|
|
1448
|
+
function createCapacitorApp(options?: CapacitorAppOptions): CapacitorAppPrimitives
|
|
1449
|
+
```
|
|
1450
|
+
|
|
1451
|
+
- `options` — Capacitor app configuration options.
|
|
1452
|
+
|
|
1453
|
+
**Returns:** Capacitor app primitives object
|
|
1454
|
+
|
|
1455
|
+
#### `createChangePassword()`
|
|
1456
|
+
|
|
1457
|
+
Creates a change password primitive with async state tracking.
|
|
1458
|
+
|
|
1459
|
+
```typescript
|
|
1460
|
+
function createChangePassword(): CreateChangePasswordReturn
|
|
1461
|
+
```
|
|
1462
|
+
|
|
1463
|
+
**Returns:** Change password state and action
|
|
1464
|
+
|
|
1465
|
+
#### `createDevice()`
|
|
1466
|
+
|
|
1467
|
+
Create device primitives for accessing device information.
|
|
1468
|
+
|
|
1469
|
+
This is a static primitive (no reactive signals) since device info
|
|
1470
|
+
does not change during the lifecycle of the app.
|
|
1471
|
+
|
|
1472
|
+
```typescript
|
|
1473
|
+
function createDevice(): DevicePrimitives
|
|
1474
|
+
```
|
|
1475
|
+
|
|
1476
|
+
**Returns:** Device primitives object
|
|
1477
|
+
|
|
1478
|
+
#### `createFieldSignal(controller, name)`
|
|
1479
|
+
|
|
1480
|
+
Create a reactive accessor for a single field's state.
|
|
1481
|
+
|
|
1482
|
+
```typescript
|
|
1483
|
+
function createFieldSignal(
|
|
1484
|
+
controller: FormController<T>,
|
|
1485
|
+
name: keyof T,
|
|
1486
|
+
): Accessor<FieldState<T[keyof T]>>
|
|
1487
|
+
```
|
|
1488
|
+
|
|
1489
|
+
- `controller` — Form controller
|
|
1490
|
+
- `name` — Field name to track
|
|
1491
|
+
|
|
1492
|
+
**Returns:** Accessor for the field state
|
|
1493
|
+
|
|
1494
|
+
#### `createForm(provider, options)`
|
|
1495
|
+
|
|
1496
|
+
Create form primitives for form state management and validation.
|
|
1497
|
+
|
|
1498
|
+
```typescript
|
|
1499
|
+
function createForm(provider: FormProvider, options: FormOptions<T>): CreateFormResult<T>
|
|
1500
|
+
```
|
|
1501
|
+
|
|
1502
|
+
- `provider` — Form provider that creates controllers
|
|
1503
|
+
- `options` — Form configuration options
|
|
1504
|
+
|
|
1505
|
+
**Returns:** Form primitives object
|
|
1506
|
+
|
|
1507
|
+
#### `createFormFromController(controller)`
|
|
1508
|
+
|
|
1509
|
+
Create form primitives from an existing controller.
|
|
1510
|
+
|
|
1511
|
+
Useful when you have a controller created externally and want to
|
|
1512
|
+
wrap it with Solid reactivity.
|
|
1513
|
+
|
|
1514
|
+
```typescript
|
|
1515
|
+
function createFormFromController(controller: FormController<T>): CreateFormResult<T>
|
|
1516
|
+
```
|
|
1517
|
+
|
|
1518
|
+
- `controller` — An existing FormController
|
|
1519
|
+
|
|
1520
|
+
**Returns:** Form primitives object
|
|
1521
|
+
|
|
1522
|
+
#### `createFormHelpers(provider)`
|
|
1523
|
+
|
|
1524
|
+
Creates a form helpers.
|
|
1525
|
+
|
|
1526
|
+
```typescript
|
|
1527
|
+
function createFormHelpers(provider: FormProvider): {
|
|
1528
|
+
createForm: <T extends Record<string, unknown>>(options: FormOptions<T>) => CreateFormResult<T>
|
|
1529
|
+
}
|
|
1530
|
+
```
|
|
1531
|
+
|
|
1532
|
+
- `provider` — The provider implementation.
|
|
1533
|
+
|
|
1534
|
+
**Returns:** The created result.
|
|
1535
|
+
|
|
1536
|
+
#### `createHttp()`
|
|
1537
|
+
|
|
1538
|
+
Creates a http.
|
|
1539
|
+
|
|
1540
|
+
```typescript
|
|
1541
|
+
function createHttp(): {
|
|
1542
|
+
get: <T>(url: string, config?: RequestConfig) => Promise<HttpResponse<T>>
|
|
1543
|
+
post: <T>(url: string, data?: unknown, config?: RequestConfig) => Promise<HttpResponse<T>>
|
|
1544
|
+
put: <T>(url: string, data?: unknown, config?: RequestConfig) => Promise<HttpResponse<T>>
|
|
1545
|
+
patch: <T>(url: string, data?: unknown, config?: RequestConfig) => Promise<HttpResponse<T>>
|
|
1546
|
+
delete: <T>(url: string, config?: RequestConfig) => Promise<HttpResponse<T>>
|
|
1547
|
+
request: <T>(config: FullRequestConfig) => Promise<HttpResponse<T>>
|
|
1548
|
+
}
|
|
1549
|
+
```
|
|
1550
|
+
|
|
1551
|
+
**Returns:** The created result.
|
|
1552
|
+
|
|
1553
|
+
#### `createHttpFromClient(client)`
|
|
1554
|
+
|
|
1555
|
+
Creates a http from client.
|
|
1556
|
+
|
|
1557
|
+
```typescript
|
|
1558
|
+
function createHttpFromClient(client: HttpClient): {
|
|
1559
|
+
get: <T>(url: string, config?: RequestConfig) => Promise<HttpResponse<T>>
|
|
1560
|
+
post: <T>(url: string, data?: unknown, config?: RequestConfig) => Promise<HttpResponse<T>>
|
|
1561
|
+
put: <T>(url: string, data?: unknown, config?: RequestConfig) => Promise<HttpResponse<T>>
|
|
1562
|
+
patch: <T>(url: string, data?: unknown, config?: RequestConfig) => Promise<HttpResponse<T>>
|
|
1563
|
+
delete: <T>(url: string, config?: RequestConfig) => Promise<HttpResponse<T>>
|
|
1564
|
+
request: <T>(config: FullRequestConfig) => Promise<HttpResponse<T>>
|
|
1565
|
+
}
|
|
1566
|
+
```
|
|
1567
|
+
|
|
1568
|
+
- `client` — The client instance.
|
|
1569
|
+
|
|
1570
|
+
**Returns:** The created result.
|
|
1571
|
+
|
|
1572
|
+
#### `createHttpHelpers()`
|
|
1573
|
+
|
|
1574
|
+
Creates a http helpers.
|
|
1575
|
+
|
|
1576
|
+
```typescript
|
|
1577
|
+
function createHttpHelpers(): {
|
|
1578
|
+
get: <T>(url: string, config?: RequestConfig) => Promise<HttpResponse<T>>
|
|
1579
|
+
post: <T>(url: string, data?: unknown, config?: RequestConfig) => Promise<HttpResponse<T>>
|
|
1580
|
+
put: <T>(url: string, data?: unknown, config?: RequestConfig) => Promise<HttpResponse<T>>
|
|
1581
|
+
patch: <T>(url: string, data?: unknown, config?: RequestConfig) => Promise<HttpResponse<T>>
|
|
1582
|
+
delete: <T>(url: string, config?: RequestConfig) => Promise<HttpResponse<T>>
|
|
1583
|
+
setAuthToken: (token: string | null) => void
|
|
1584
|
+
getAuthToken: () => string | null
|
|
1585
|
+
}
|
|
1586
|
+
```
|
|
1587
|
+
|
|
1588
|
+
**Returns:** The created result.
|
|
1589
|
+
|
|
1590
|
+
#### `createI18n()`
|
|
1591
|
+
|
|
1592
|
+
Creates a i18n.
|
|
1593
|
+
|
|
1594
|
+
```typescript
|
|
1595
|
+
function createI18n(): {
|
|
1596
|
+
t: TranslateFunction
|
|
1597
|
+
locale: Accessor<string>
|
|
1598
|
+
setLocale: (newLocale: string) => Promise<void>
|
|
1599
|
+
isReady: Accessor<boolean>
|
|
1600
|
+
getLocales: () => LocaleConfig[]
|
|
1601
|
+
hasKey: (key: string) => boolean
|
|
1602
|
+
}
|
|
1603
|
+
```
|
|
1604
|
+
|
|
1605
|
+
**Returns:** The created result.
|
|
1606
|
+
|
|
1607
|
+
#### `createI18nFromProvider(provider)`
|
|
1608
|
+
|
|
1609
|
+
Creates a i18n from provider.
|
|
1610
|
+
|
|
1611
|
+
```typescript
|
|
1612
|
+
function createI18nFromProvider(provider: I18nProvider): {
|
|
1613
|
+
t: TranslateFunction
|
|
1614
|
+
locale: Accessor<string>
|
|
1615
|
+
setLocale: (newLocale: string) => Promise<void>
|
|
1616
|
+
isReady: Accessor<boolean>
|
|
1617
|
+
getLocales: () => LocaleConfig[]
|
|
1618
|
+
hasKey: (key: string) => boolean
|
|
1619
|
+
}
|
|
1620
|
+
```
|
|
1621
|
+
|
|
1622
|
+
- `provider` — The provider implementation.
|
|
1623
|
+
|
|
1624
|
+
**Returns:** The created result.
|
|
1625
|
+
|
|
1626
|
+
#### `createI18nHelpers()`
|
|
1627
|
+
|
|
1628
|
+
Creates a i18n helpers.
|
|
1629
|
+
|
|
1630
|
+
```typescript
|
|
1631
|
+
function createI18nHelpers(): {
|
|
1632
|
+
t: TranslateFunction
|
|
1633
|
+
getLocale: () => string
|
|
1634
|
+
setLocale: (locale: string) => Promise<void>
|
|
1635
|
+
getLocales: () => LocaleConfig[]
|
|
1636
|
+
hasKey: (key: string) => boolean
|
|
1637
|
+
isReady: () => boolean
|
|
1638
|
+
}
|
|
1639
|
+
```
|
|
1640
|
+
|
|
1641
|
+
**Returns:** The created result.
|
|
1642
|
+
|
|
1643
|
+
#### `createIsActive(path, exact)`
|
|
1644
|
+
|
|
1645
|
+
Create a reactive boolean accessor that tracks whether a given path is active.
|
|
1646
|
+
|
|
1647
|
+
Unlike `useMatch` which only accepts a static pattern, this factory returns
|
|
1648
|
+
a signal that re-evaluates on every route change and supports the `exact`
|
|
1649
|
+
parameter from the router's `isActive` method.
|
|
1650
|
+
|
|
1651
|
+
```typescript
|
|
1652
|
+
function createIsActive(path: string, exact?: boolean): Accessor<boolean>
|
|
1653
|
+
```
|
|
1654
|
+
|
|
1655
|
+
- `path` — Path to check against the current location
|
|
1656
|
+
- `exact` — Whether to require an exact match (default: false)
|
|
1657
|
+
|
|
1658
|
+
**Returns:** Accessor<boolean> that is true when the path is active
|
|
1659
|
+
|
|
1660
|
+
#### `createLogger(config)`
|
|
1661
|
+
|
|
1662
|
+
Create a logger with custom configuration.
|
|
1663
|
+
|
|
1664
|
+
```typescript
|
|
1665
|
+
function createLogger(config: LoggerConfig): Logger
|
|
1666
|
+
```
|
|
1667
|
+
|
|
1668
|
+
- `config` — Logger configuration
|
|
1669
|
+
|
|
1670
|
+
**Returns:** Logger instance
|
|
1671
|
+
|
|
1672
|
+
#### `createLoggerFromProvider(provider, name)`
|
|
1673
|
+
|
|
1674
|
+
Create logger from a specific provider.
|
|
1675
|
+
|
|
1676
|
+
```typescript
|
|
1677
|
+
function createLoggerFromProvider(provider: LoggerProvider, name?: string): Logger
|
|
1678
|
+
```
|
|
1679
|
+
|
|
1680
|
+
- `provider` — Logger provider
|
|
1681
|
+
- `name` — Logger name
|
|
1682
|
+
|
|
1683
|
+
**Returns:** Logger instance
|
|
1684
|
+
|
|
1685
|
+
#### `createLoggerHelpers()`
|
|
1686
|
+
|
|
1687
|
+
Creates a logger helpers.
|
|
1688
|
+
|
|
1689
|
+
```typescript
|
|
1690
|
+
function createLoggerHelpers(): {
|
|
1691
|
+
getLogger: (name?: string) => Logger
|
|
1692
|
+
createLogger: (config: LoggerConfig) => Logger
|
|
1693
|
+
setLevel: (level: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent') => void
|
|
1694
|
+
getLevel: () => string
|
|
1695
|
+
enable: () => void
|
|
1696
|
+
disable: () => void
|
|
1697
|
+
isEnabled: () => boolean
|
|
1698
|
+
}
|
|
1699
|
+
```
|
|
1700
|
+
|
|
1701
|
+
**Returns:** The created result.
|
|
1702
|
+
|
|
1703
|
+
#### `createLoggerHelpersFromProvider(provider)`
|
|
1704
|
+
|
|
1705
|
+
Creates a logger helpers from provider.
|
|
1706
|
+
|
|
1707
|
+
```typescript
|
|
1708
|
+
function createLoggerHelpersFromProvider(provider: LoggerProvider): {
|
|
1709
|
+
getLogger: (name?: string) => Logger
|
|
1710
|
+
createLogger: (config: LoggerConfig) => Logger
|
|
1711
|
+
setLevel: (level: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent') => void
|
|
1712
|
+
getLevel: () => string
|
|
1713
|
+
enable: () => void
|
|
1714
|
+
disable: () => void
|
|
1715
|
+
isEnabled: () => boolean
|
|
1716
|
+
}
|
|
1717
|
+
```
|
|
1718
|
+
|
|
1719
|
+
- `provider` — The provider implementation.
|
|
1720
|
+
|
|
1721
|
+
**Returns:** The created result.
|
|
1722
|
+
|
|
1723
|
+
#### `createLogin()`
|
|
1724
|
+
|
|
1725
|
+
Creates a login primitive with async state tracking.
|
|
1726
|
+
|
|
1727
|
+
```typescript
|
|
1728
|
+
function createLogin(): CreateLoginReturn<T>
|
|
1729
|
+
```
|
|
1730
|
+
|
|
1731
|
+
**Returns:** Login state and action
|
|
1732
|
+
|
|
1733
|
+
#### `createOAuth(options)`
|
|
1734
|
+
|
|
1735
|
+
Creates OAuth helpers.
|
|
1736
|
+
|
|
1737
|
+
Automatically handles OAuth callbacks by detecting `code` and `state` URL
|
|
1738
|
+
parameters and exchanging them for a session:
|
|
1739
|
+
|
|
1740
|
+
- Inside a Solid owner (component setup / `createRoot`), the callback
|
|
1741
|
+
handling is deferred to `onMount` so it runs client-side after mount.
|
|
1742
|
+
- Outside an owner (a plain function call, e.g. bootstrap code), it runs
|
|
1743
|
+
immediately at creation, browser-guarded.
|
|
1744
|
+
|
|
1745
|
+
```typescript
|
|
1746
|
+
function createOAuth(options?: CreateOAuthOptions): CreateOAuthReturn
|
|
1747
|
+
```
|
|
1748
|
+
|
|
1749
|
+
- `options` — OAuth configuration
|
|
1750
|
+
|
|
1751
|
+
**Returns:** The created instance.
|
|
1752
|
+
|
|
1753
|
+
#### `createPasswordReset()`
|
|
1754
|
+
|
|
1755
|
+
Creates a password reset primitive with async state tracking.
|
|
1756
|
+
|
|
1757
|
+
```typescript
|
|
1758
|
+
function createPasswordReset(): CreatePasswordResetReturn
|
|
1759
|
+
```
|
|
1760
|
+
|
|
1761
|
+
**Returns:** Password reset state and actions
|
|
1762
|
+
|
|
1763
|
+
#### `createPersistedStore(key, initial, storage)`
|
|
1764
|
+
|
|
1765
|
+
Create a persisted signal store.
|
|
1766
|
+
|
|
1767
|
+
```typescript
|
|
1768
|
+
function createPersistedStore(
|
|
1769
|
+
key: string,
|
|
1770
|
+
initial: T,
|
|
1771
|
+
storage: StorageAdapter,
|
|
1772
|
+
): [Accessor<T>, (value: T | ((prev: T) => T)) => void]
|
|
1773
|
+
```
|
|
1774
|
+
|
|
1775
|
+
- `key` — Storage key
|
|
1776
|
+
- `initial` — Initial value
|
|
1777
|
+
- `storage` — Storage adapter (required - use localStorage, sessionStorage, or `@molecule/app-storage`)
|
|
1778
|
+
|
|
1779
|
+
**Returns:** Tuple of accessor and setter
|
|
1780
|
+
|
|
1781
|
+
#### `createPlatform()`
|
|
1782
|
+
|
|
1783
|
+
Create platform primitives for detecting the current platform.
|
|
1784
|
+
|
|
1785
|
+
This is a static primitive (no reactive signals) since the platform
|
|
1786
|
+
does not change during the lifecycle of the app.
|
|
1787
|
+
|
|
1788
|
+
```typescript
|
|
1789
|
+
function createPlatform(): PlatformPrimitives
|
|
1790
|
+
```
|
|
1791
|
+
|
|
1792
|
+
**Returns:** Platform primitives object
|
|
1793
|
+
|
|
1794
|
+
#### `createPromise(asyncFn)`
|
|
1795
|
+
|
|
1796
|
+
Primitive that wraps an async function with reactive state tracking.
|
|
1797
|
+
|
|
1798
|
+
```typescript
|
|
1799
|
+
function createPromise(asyncFn: T): CreatePromiseReturn<Awaited<ReturnType<T>>>
|
|
1800
|
+
```
|
|
1801
|
+
|
|
1802
|
+
- `asyncFn` — The async function to wrap
|
|
1803
|
+
|
|
1804
|
+
**Returns:** Object with state accessor, call, cancel, and reset functions
|
|
1805
|
+
|
|
1806
|
+
#### `createPush()`
|
|
1807
|
+
|
|
1808
|
+
Create push notification primitives.
|
|
1809
|
+
|
|
1810
|
+
```typescript
|
|
1811
|
+
function createPush(): PushPrimitives
|
|
1812
|
+
```
|
|
1813
|
+
|
|
1814
|
+
**Returns:** Push primitives object
|
|
1815
|
+
|
|
1816
|
+
#### `createRouter()`
|
|
1817
|
+
|
|
1818
|
+
Create router primitives for navigation state and actions.
|
|
1819
|
+
|
|
1820
|
+
```typescript
|
|
1821
|
+
function createRouter(): RouterPrimitives
|
|
1822
|
+
```
|
|
1823
|
+
|
|
1824
|
+
**Returns:** Router primitives object
|
|
1825
|
+
|
|
1826
|
+
#### `createRouterFromInstance(router)`
|
|
1827
|
+
|
|
1828
|
+
Create router primitives from a specific router.
|
|
1829
|
+
|
|
1830
|
+
```typescript
|
|
1831
|
+
function createRouterFromInstance(router: Router): RouterPrimitives
|
|
1832
|
+
```
|
|
1833
|
+
|
|
1834
|
+
- `router` — Router instance
|
|
1835
|
+
|
|
1836
|
+
**Returns:** Router primitives
|
|
1837
|
+
|
|
1838
|
+
#### `createRouterHelpers()`
|
|
1839
|
+
|
|
1840
|
+
Creates a router helpers.
|
|
1841
|
+
|
|
1842
|
+
```typescript
|
|
1843
|
+
function createRouterHelpers(): {
|
|
1844
|
+
navigate: (path: string, options?: NavigateOptions) => void
|
|
1845
|
+
navigateTo: (
|
|
1846
|
+
name: string,
|
|
1847
|
+
params?: RouteParams,
|
|
1848
|
+
query?: QueryParams,
|
|
1849
|
+
options?: NavigateOptions,
|
|
1850
|
+
) => void
|
|
1851
|
+
back: () => void
|
|
1852
|
+
forward: () => void
|
|
1853
|
+
getLocation: () => RouteLocation
|
|
1854
|
+
getParams: () => RouteParams
|
|
1855
|
+
getQuery: () => QueryParams
|
|
1856
|
+
isActive: (path: string) => boolean
|
|
1857
|
+
}
|
|
1858
|
+
```
|
|
1859
|
+
|
|
1860
|
+
**Returns:** The created result.
|
|
1861
|
+
|
|
1862
|
+
#### `createSignalStore(initial)`
|
|
1863
|
+
|
|
1864
|
+
Create a simple signal-based store without provider.
|
|
1865
|
+
|
|
1866
|
+
```typescript
|
|
1867
|
+
function createSignalStore(initial: T): [Accessor<T>, (value: T | ((prev: T) => T)) => void]
|
|
1868
|
+
```
|
|
1869
|
+
|
|
1870
|
+
- `initial` — Initial state
|
|
1871
|
+
|
|
1872
|
+
**Returns:** The created instance.
|
|
1873
|
+
|
|
1874
|
+
#### `createSignup()`
|
|
1875
|
+
|
|
1876
|
+
Creates a signup primitive with async state tracking.
|
|
1877
|
+
|
|
1878
|
+
```typescript
|
|
1879
|
+
function createSignup(): CreateSignupReturn<T>
|
|
1880
|
+
```
|
|
1881
|
+
|
|
1882
|
+
**Returns:** Signup state and action
|
|
1883
|
+
|
|
1884
|
+
#### `createStateHelpers()`
|
|
1885
|
+
|
|
1886
|
+
Creates a state helpers.
|
|
1887
|
+
|
|
1888
|
+
```typescript
|
|
1889
|
+
function createStateHelpers(): {
|
|
1890
|
+
createStore: <T extends object>(config: StoreConfig<T>) => Store<T>
|
|
1891
|
+
}
|
|
1892
|
+
```
|
|
1893
|
+
|
|
1894
|
+
**Returns:** The created result.
|
|
1895
|
+
|
|
1896
|
+
#### `createStateHelpersFromProvider(provider)`
|
|
1897
|
+
|
|
1898
|
+
Creates a state helpers from provider.
|
|
1899
|
+
|
|
1900
|
+
```typescript
|
|
1901
|
+
function createStateHelpersFromProvider(provider: StateProvider): {
|
|
1902
|
+
createStore: <T extends object>(config: StoreConfig<T>) => Store<T>
|
|
1903
|
+
}
|
|
1904
|
+
```
|
|
1905
|
+
|
|
1906
|
+
- `provider` — The provider implementation.
|
|
1907
|
+
|
|
1908
|
+
**Returns:** The created result.
|
|
1909
|
+
|
|
1910
|
+
#### `createStorage()`
|
|
1911
|
+
|
|
1912
|
+
Create storage primitives.
|
|
1913
|
+
|
|
1914
|
+
```typescript
|
|
1915
|
+
function createStorage(): {
|
|
1916
|
+
get: <T>(key: string) => Promise<T | null>
|
|
1917
|
+
set: <T>(key: string, value: T) => Promise<void>
|
|
1918
|
+
remove: (key: string) => Promise<void>
|
|
1919
|
+
clear: () => Promise<void>
|
|
1920
|
+
keys: () => Promise<string[]>
|
|
1921
|
+
}
|
|
1922
|
+
```
|
|
1923
|
+
|
|
1924
|
+
**Returns:** Storage methods
|
|
1925
|
+
|
|
1926
|
+
#### `createStorageFromProvider(storage)`
|
|
1927
|
+
|
|
1928
|
+
Create storage primitives from a specific provider.
|
|
1929
|
+
|
|
1930
|
+
```typescript
|
|
1931
|
+
function createStorageFromProvider(storage: StorageProvider): {
|
|
1932
|
+
get: <T>(key: string) => Promise<T | null>
|
|
1933
|
+
set: <T>(key: string, value: T) => Promise<void>
|
|
1934
|
+
remove: (key: string) => Promise<void>
|
|
1935
|
+
clear: () => Promise<void>
|
|
1936
|
+
keys: () => Promise<string[]>
|
|
1937
|
+
}
|
|
1938
|
+
```
|
|
1939
|
+
|
|
1940
|
+
- `storage` — Storage provider
|
|
1941
|
+
|
|
1942
|
+
**Returns:** Storage methods
|
|
1943
|
+
|
|
1944
|
+
#### `createStorageHelpers()`
|
|
1945
|
+
|
|
1946
|
+
Create storage helpers from context.
|
|
1947
|
+
|
|
1948
|
+
```typescript
|
|
1949
|
+
function createStorageHelpers(): {
|
|
1950
|
+
get: <T>(key: string) => Promise<T | null>
|
|
1951
|
+
set: <T>(key: string, value: T) => Promise<void>
|
|
1952
|
+
remove: (key: string) => Promise<void>
|
|
1953
|
+
clear: () => Promise<void>
|
|
1954
|
+
keys: () => Promise<string[]>
|
|
1955
|
+
}
|
|
1956
|
+
```
|
|
1957
|
+
|
|
1958
|
+
**Returns:** Storage helper functions
|
|
1959
|
+
|
|
1960
|
+
#### `createStorageValue(key, defaultValue)`
|
|
1961
|
+
|
|
1962
|
+
Create a storage value primitive.
|
|
1963
|
+
|
|
1964
|
+
```typescript
|
|
1965
|
+
function createStorageValue(
|
|
1966
|
+
key: string,
|
|
1967
|
+
defaultValue?: T,
|
|
1968
|
+
): {
|
|
1969
|
+
value: () => T | undefined
|
|
1970
|
+
loading: () => boolean
|
|
1971
|
+
error: () => Error | null
|
|
1972
|
+
set: (value: T) => Promise<void>
|
|
1973
|
+
remove: () => Promise<void>
|
|
1974
|
+
refresh: () => Promise<T | undefined>
|
|
1975
|
+
}
|
|
1976
|
+
```
|
|
1977
|
+
|
|
1978
|
+
- `key` — Storage key
|
|
1979
|
+
- `defaultValue` — Default value if not found
|
|
1980
|
+
|
|
1981
|
+
**Returns:** Storage value accessor and actions
|
|
1982
|
+
|
|
1983
|
+
#### `createStorageValueFromProvider(storage, key, defaultValue)`
|
|
1984
|
+
|
|
1985
|
+
Create storage value primitive from a specific provider.
|
|
1986
|
+
|
|
1987
|
+
```typescript
|
|
1988
|
+
function createStorageValueFromProvider(
|
|
1989
|
+
storage: StorageProvider,
|
|
1990
|
+
key: string,
|
|
1991
|
+
defaultValue?: T,
|
|
1992
|
+
): {
|
|
1993
|
+
value: () => T | undefined
|
|
1994
|
+
loading: () => boolean
|
|
1995
|
+
error: () => Error | null
|
|
1996
|
+
set: (value: T) => Promise<void>
|
|
1997
|
+
remove: () => Promise<void>
|
|
1998
|
+
}
|
|
1999
|
+
```
|
|
2000
|
+
|
|
2001
|
+
- `storage` — Storage provider
|
|
2002
|
+
- `key` — Storage key
|
|
2003
|
+
- `defaultValue` — Default value
|
|
2004
|
+
|
|
2005
|
+
**Returns:** Storage value accessor and actions
|
|
2006
|
+
|
|
2007
|
+
#### `createStore(config)`
|
|
2008
|
+
|
|
2009
|
+
Create a reactive store using Solid signals.
|
|
2010
|
+
|
|
2011
|
+
```typescript
|
|
2012
|
+
function createStore(config: StoreConfig<T>): Store<T>
|
|
2013
|
+
```
|
|
2014
|
+
|
|
2015
|
+
- `config` — Store configuration
|
|
2016
|
+
|
|
2017
|
+
**Returns:** Store instance
|
|
2018
|
+
|
|
2019
|
+
#### `createTheme()`
|
|
2020
|
+
|
|
2021
|
+
Create theme primitives for theme state and actions.
|
|
2022
|
+
|
|
2023
|
+
```typescript
|
|
2024
|
+
function createTheme(): ThemePrimitives
|
|
2025
|
+
```
|
|
2026
|
+
|
|
2027
|
+
**Returns:** The created instance.
|
|
2028
|
+
|
|
2029
|
+
#### `createThemeColors(theme)`
|
|
2030
|
+
|
|
2031
|
+
Create a colors accessor derived from a theme accessor.
|
|
2032
|
+
|
|
2033
|
+
```typescript
|
|
2034
|
+
function createThemeColors(theme: Accessor<Theme>): Accessor<ThemeColors>
|
|
2035
|
+
```
|
|
2036
|
+
|
|
2037
|
+
- `theme` — Theme accessor (e.g. from createTheme().theme)
|
|
2038
|
+
|
|
2039
|
+
**Returns:** Accessor for the current theme colors
|
|
2040
|
+
|
|
2041
|
+
#### `createThemeFromProvider(provider)`
|
|
2042
|
+
|
|
2043
|
+
Create theme primitives from a specific provider.
|
|
2044
|
+
|
|
2045
|
+
```typescript
|
|
2046
|
+
function createThemeFromProvider(provider: ThemeProvider): ThemePrimitives
|
|
2047
|
+
```
|
|
2048
|
+
|
|
2049
|
+
- `provider` — Theme provider
|
|
2050
|
+
|
|
2051
|
+
**Returns:** Theme primitives
|
|
2052
|
+
|
|
2053
|
+
#### `createThemeHelpers()`
|
|
2054
|
+
|
|
2055
|
+
Creates a theme helpers.
|
|
2056
|
+
|
|
2057
|
+
```typescript
|
|
2058
|
+
function createThemeHelpers(): {
|
|
2059
|
+
getTheme: () => Theme
|
|
2060
|
+
setTheme: (name: string) => void
|
|
2061
|
+
getMode: () => 'light' | 'dark'
|
|
2062
|
+
toggleMode: () => void
|
|
2063
|
+
getAvailableThemes: () => Theme[]
|
|
2064
|
+
}
|
|
2065
|
+
```
|
|
2066
|
+
|
|
2067
|
+
**Returns:** The created result.
|
|
2068
|
+
|
|
2069
|
+
#### `createVersion()`
|
|
2070
|
+
|
|
2071
|
+
Create version primitives for tracking app updates.
|
|
2072
|
+
|
|
2073
|
+
```typescript
|
|
2074
|
+
function createVersion(): VersionPrimitives
|
|
2075
|
+
```
|
|
2076
|
+
|
|
2077
|
+
**Returns:** Version primitives object
|
|
2078
|
+
|
|
2079
|
+
#### `createWatchSignal(controller, name)`
|
|
2080
|
+
|
|
2081
|
+
Create a reactive accessor that tracks a single field's value.
|
|
2082
|
+
|
|
2083
|
+
```typescript
|
|
2084
|
+
function createWatchSignal(controller: FormController<T>, name: K): Accessor<T[K]>
|
|
2085
|
+
```
|
|
2086
|
+
|
|
2087
|
+
- `controller` — Form controller
|
|
2088
|
+
- `name` — Field name to watch
|
|
2089
|
+
|
|
2090
|
+
**Returns:** Accessor for the field value
|
|
2091
|
+
|
|
2092
|
+
#### `getAuthClient()`
|
|
2093
|
+
|
|
2094
|
+
Get the auth client from context.
|
|
2095
|
+
|
|
2096
|
+
```typescript
|
|
2097
|
+
function getAuthClient(): AuthClient<T>
|
|
2098
|
+
```
|
|
2099
|
+
|
|
2100
|
+
**Returns:** The auth client instance.
|
|
2101
|
+
|
|
2102
|
+
#### `getChildLogger(name, context)`
|
|
2103
|
+
|
|
2104
|
+
Create a child logger with additional context.
|
|
2105
|
+
|
|
2106
|
+
```typescript
|
|
2107
|
+
function getChildLogger(name: string, context: Record<string, unknown>): Logger
|
|
2108
|
+
```
|
|
2109
|
+
|
|
2110
|
+
- `name` — Parent logger name
|
|
2111
|
+
- `context` — Additional context
|
|
2112
|
+
|
|
2113
|
+
**Returns:** Child logger instance
|
|
2114
|
+
|
|
2115
|
+
#### `getHttpClient()`
|
|
2116
|
+
|
|
2117
|
+
Get the HTTP client from context.
|
|
2118
|
+
|
|
2119
|
+
```typescript
|
|
2120
|
+
function getHttpClient(): HttpClient
|
|
2121
|
+
```
|
|
2122
|
+
|
|
2123
|
+
**Returns:** The HTTP client instance.
|
|
2124
|
+
|
|
2125
|
+
#### `getI18nProvider()`
|
|
2126
|
+
|
|
2127
|
+
Get the i18n provider from context.
|
|
2128
|
+
|
|
2129
|
+
```typescript
|
|
2130
|
+
function getI18nProvider(): I18nProvider
|
|
2131
|
+
```
|
|
2132
|
+
|
|
2133
|
+
**Returns:** The i18n provider instance.
|
|
2134
|
+
|
|
2135
|
+
#### `getLogger(name)`
|
|
2136
|
+
|
|
2137
|
+
Get a logger instance.
|
|
2138
|
+
|
|
2139
|
+
```typescript
|
|
2140
|
+
function getLogger(name?: string): Logger
|
|
2141
|
+
```
|
|
2142
|
+
|
|
2143
|
+
- `name` — Logger name
|
|
2144
|
+
|
|
2145
|
+
**Returns:** Logger instance
|
|
2146
|
+
|
|
2147
|
+
#### `getLoggerProvider()`
|
|
2148
|
+
|
|
2149
|
+
Get the logger provider from context.
|
|
2150
|
+
|
|
2151
|
+
```typescript
|
|
2152
|
+
function getLoggerProvider(): LoggerProvider
|
|
2153
|
+
```
|
|
2154
|
+
|
|
2155
|
+
**Returns:** The logger provider instance.
|
|
2156
|
+
|
|
2157
|
+
#### `getRootLogger()`
|
|
2158
|
+
|
|
2159
|
+
Get the root logger.
|
|
2160
|
+
|
|
2161
|
+
```typescript
|
|
2162
|
+
function getRootLogger(): Logger
|
|
2163
|
+
```
|
|
2164
|
+
|
|
2165
|
+
**Returns:** Root logger instance
|
|
2166
|
+
|
|
2167
|
+
#### `getRouter()`
|
|
2168
|
+
|
|
2169
|
+
Get the router from context.
|
|
2170
|
+
|
|
2171
|
+
```typescript
|
|
2172
|
+
function getRouter(): Router
|
|
2173
|
+
```
|
|
2174
|
+
|
|
2175
|
+
**Returns:** The router instance.
|
|
2176
|
+
|
|
2177
|
+
#### `getStateProvider()`
|
|
2178
|
+
|
|
2179
|
+
Get the state provider from context.
|
|
2180
|
+
|
|
2181
|
+
```typescript
|
|
2182
|
+
function getStateProvider(): StateProvider
|
|
2183
|
+
```
|
|
2184
|
+
|
|
2185
|
+
**Returns:** The state provider instance.
|
|
2186
|
+
|
|
2187
|
+
#### `getStorageProvider()`
|
|
2188
|
+
|
|
2189
|
+
Get the storage provider from context.
|
|
2190
|
+
|
|
2191
|
+
```typescript
|
|
2192
|
+
function getStorageProvider(): StorageProvider
|
|
2193
|
+
```
|
|
2194
|
+
|
|
2195
|
+
**Returns:** The storage provider instance.
|
|
2196
|
+
|
|
2197
|
+
#### `getThemeProvider()`
|
|
2198
|
+
|
|
2199
|
+
Get the theme provider from context.
|
|
2200
|
+
|
|
2201
|
+
```typescript
|
|
2202
|
+
function getThemeProvider(): ThemeProvider
|
|
2203
|
+
```
|
|
2204
|
+
|
|
2205
|
+
**Returns:** The theme provider instance.
|
|
2206
|
+
|
|
2207
|
+
#### `MoleculeProvider(props)`
|
|
2208
|
+
|
|
2209
|
+
MoleculeProvider component that provides all molecule services to the component tree.
|
|
2210
|
+
|
|
2211
|
+
```typescript
|
|
2212
|
+
function MoleculeProvider(props: ParentProps<{ config: MoleculeConfig }>): JSX.Element
|
|
2213
|
+
```
|
|
2214
|
+
|
|
2215
|
+
- `props` — Component props containing the molecule config.
|
|
2216
|
+
|
|
2217
|
+
**Returns:** The nested provider tree wrapping children.
|
|
2218
|
+
|
|
2219
|
+
#### `useComponentLogger(componentName)`
|
|
2220
|
+
|
|
2221
|
+
Create a component logger that includes component name in context.
|
|
2222
|
+
|
|
2223
|
+
```typescript
|
|
2224
|
+
function useComponentLogger(componentName: string): Logger
|
|
2225
|
+
```
|
|
2226
|
+
|
|
2227
|
+
- `componentName` — Name of the component
|
|
2228
|
+
|
|
2229
|
+
**Returns:** Logger configured for the component
|
|
2230
|
+
|
|
2231
|
+
#### `useFetch(url, config)`
|
|
2232
|
+
|
|
2233
|
+
Create a resource for fetching data.
|
|
2234
|
+
|
|
2235
|
+
```typescript
|
|
2236
|
+
function useFetch(url: string | Accessor<string>, config?: RequestConfig): Resource<T | undefined>
|
|
2237
|
+
```
|
|
2238
|
+
|
|
2239
|
+
- `url` — URL string or accessor returning a URL string.
|
|
2240
|
+
- `config` — Optional request configuration.
|
|
2241
|
+
|
|
2242
|
+
**Returns:** Solid resource
|
|
2243
|
+
|
|
2244
|
+
#### `useLazyQuery()`
|
|
2245
|
+
|
|
2246
|
+
Hook for lazy query.
|
|
2247
|
+
|
|
2248
|
+
```typescript
|
|
2249
|
+
function useLazyQuery(): {
|
|
2250
|
+
execute: (url: string, config?: RequestConfig) => Promise<T>
|
|
2251
|
+
data: () => T | null
|
|
2252
|
+
isLoading: () => boolean
|
|
2253
|
+
error: () => Error | null
|
|
2254
|
+
reset: () => void
|
|
2255
|
+
}
|
|
2256
|
+
```
|
|
2257
|
+
|
|
2258
|
+
**Returns:** The result.
|
|
2259
|
+
|
|
2260
|
+
#### `useLocale()`
|
|
2261
|
+
|
|
2262
|
+
Get current locale as accessor.
|
|
2263
|
+
|
|
2264
|
+
```typescript
|
|
2265
|
+
function useLocale(): Accessor<string>
|
|
2266
|
+
```
|
|
2267
|
+
|
|
2268
|
+
**Returns:** Accessor for current locale
|
|
2269
|
+
|
|
2270
|
+
#### `useLocation()`
|
|
2271
|
+
|
|
2272
|
+
Get current route location as accessor.
|
|
2273
|
+
|
|
2274
|
+
```typescript
|
|
2275
|
+
function useLocation(): Accessor<RouteLocation>
|
|
2276
|
+
```
|
|
2277
|
+
|
|
2278
|
+
**Returns:** Accessor for current location
|
|
2279
|
+
|
|
2280
|
+
#### `useMatch(pattern)`
|
|
2281
|
+
|
|
2282
|
+
Create a match accessor for a path pattern.
|
|
2283
|
+
|
|
2284
|
+
```typescript
|
|
2285
|
+
function useMatch(pattern: string): Accessor<boolean>
|
|
2286
|
+
```
|
|
2287
|
+
|
|
2288
|
+
- `pattern` — Path pattern to match
|
|
2289
|
+
|
|
2290
|
+
**Returns:** Accessor indicating if current path matches
|
|
2291
|
+
|
|
2292
|
+
#### `useMode()`
|
|
2293
|
+
|
|
2294
|
+
Create a mode accessor.
|
|
2295
|
+
|
|
2296
|
+
```typescript
|
|
2297
|
+
function useMode(): Accessor<'light' | 'dark'>
|
|
2298
|
+
```
|
|
2299
|
+
|
|
2300
|
+
**Returns:** Accessor for current mode
|
|
2301
|
+
|
|
2302
|
+
#### `useMutation()`
|
|
2303
|
+
|
|
2304
|
+
Hook for mutation.
|
|
2305
|
+
|
|
2306
|
+
```typescript
|
|
2307
|
+
function useMutation(): {
|
|
2308
|
+
mutate: (
|
|
2309
|
+
url: string,
|
|
2310
|
+
payload?: unknown,
|
|
2311
|
+
method?: 'POST' | 'PUT' | 'PATCH' | 'DELETE',
|
|
2312
|
+
) => Promise<T>
|
|
2313
|
+
isLoading: Accessor<boolean>
|
|
2314
|
+
error: Accessor<Error | null>
|
|
2315
|
+
data: Accessor<T | null>
|
|
2316
|
+
reset: () => void
|
|
2317
|
+
}
|
|
2318
|
+
```
|
|
2319
|
+
|
|
2320
|
+
**Returns:** The result.
|
|
2321
|
+
|
|
2322
|
+
#### `useNavigate()`
|
|
2323
|
+
|
|
2324
|
+
Get navigate function.
|
|
2325
|
+
|
|
2326
|
+
```typescript
|
|
2327
|
+
function useNavigate(): (path: string, options?: NavigateOptions) => void
|
|
2328
|
+
```
|
|
2329
|
+
|
|
2330
|
+
**Returns:** Navigate function
|
|
2331
|
+
|
|
2332
|
+
#### `useParams()`
|
|
2333
|
+
|
|
2334
|
+
Get current route params as accessor.
|
|
2335
|
+
|
|
2336
|
+
```typescript
|
|
2337
|
+
function useParams(): Accessor<RouteParams>
|
|
2338
|
+
```
|
|
2339
|
+
|
|
2340
|
+
**Returns:** Accessor for route params
|
|
2341
|
+
|
|
2342
|
+
#### `usePersistedSignal(key, defaultValue)`
|
|
2343
|
+
|
|
2344
|
+
Create a persisted signal that syncs with storage.
|
|
2345
|
+
|
|
2346
|
+
```typescript
|
|
2347
|
+
function usePersistedSignal(
|
|
2348
|
+
key: string,
|
|
2349
|
+
defaultValue: T,
|
|
2350
|
+
): [Accessor<T | undefined>, (value: T | ((prev: T | undefined) => T)) => void]
|
|
2351
|
+
```
|
|
2352
|
+
|
|
2353
|
+
- `key` — Storage key
|
|
2354
|
+
- `defaultValue` — Default value
|
|
2355
|
+
|
|
2356
|
+
**Returns:** Tuple of accessor and setter
|
|
2357
|
+
|
|
2358
|
+
#### `usePlural(key, count, values)`
|
|
2359
|
+
|
|
2360
|
+
Create a reactive plural translation.
|
|
2361
|
+
|
|
2362
|
+
```typescript
|
|
2363
|
+
function usePlural(
|
|
2364
|
+
key: string,
|
|
2365
|
+
count: Accessor<number>,
|
|
2366
|
+
values?: InterpolationValues,
|
|
2367
|
+
): Accessor<string>
|
|
2368
|
+
```
|
|
2369
|
+
|
|
2370
|
+
- `key` — Translation key
|
|
2371
|
+
- `count` — Count accessor for pluralization
|
|
2372
|
+
- `values` — Interpolation values for the translation.
|
|
2373
|
+
|
|
2374
|
+
**Returns:** Accessor for translated string
|
|
2375
|
+
|
|
2376
|
+
#### `useQuery()`
|
|
2377
|
+
|
|
2378
|
+
Get current query params as accessor.
|
|
2379
|
+
|
|
2380
|
+
```typescript
|
|
2381
|
+
function useQuery(): Accessor<QueryParams>
|
|
2382
|
+
```
|
|
2383
|
+
|
|
2384
|
+
**Returns:** Accessor for query params
|
|
2385
|
+
|
|
2386
|
+
#### `useStore(store, selector)`
|
|
2387
|
+
|
|
2388
|
+
Use a store with optional selector, returning an accessor.
|
|
2389
|
+
|
|
2390
|
+
```typescript
|
|
2391
|
+
function useStore(store: Store<T>, selector?: (state: T) => S): Accessor<S>
|
|
2392
|
+
```
|
|
2393
|
+
|
|
2394
|
+
- `store` — Store to subscribe to
|
|
2395
|
+
- `selector` — Optional selector function
|
|
2396
|
+
|
|
2397
|
+
**Returns:** Accessor for selected state
|
|
2398
|
+
|
|
2399
|
+
#### `useThemeName()`
|
|
2400
|
+
|
|
2401
|
+
Create a theme name accessor.
|
|
2402
|
+
|
|
2403
|
+
```typescript
|
|
2404
|
+
function useThemeName(): Accessor<string>
|
|
2405
|
+
```
|
|
2406
|
+
|
|
2407
|
+
**Returns:** Accessor for current theme name
|
|
2408
|
+
|
|
2409
|
+
#### `useTranslate()`
|
|
2410
|
+
|
|
2411
|
+
Get translate function.
|
|
2412
|
+
|
|
2413
|
+
```typescript
|
|
2414
|
+
function useTranslate(): TranslateFunction
|
|
2415
|
+
```
|
|
2416
|
+
|
|
2417
|
+
**Returns:** Translate function
|
|
2418
|
+
|
|
2419
|
+
#### `useTranslation(key, values, options)`
|
|
2420
|
+
|
|
2421
|
+
Create a reactive translation.
|
|
2422
|
+
|
|
2423
|
+
```typescript
|
|
2424
|
+
function useTranslation(
|
|
2425
|
+
key: string,
|
|
2426
|
+
values?: InterpolationValues,
|
|
2427
|
+
options?: TranslateOptions,
|
|
2428
|
+
): Accessor<string>
|
|
2429
|
+
```
|
|
2430
|
+
|
|
2431
|
+
- `key` — Translation key
|
|
2432
|
+
- `values` — Interpolation values for the translation.
|
|
2433
|
+
- `options` — Translation options
|
|
2434
|
+
|
|
2435
|
+
**Returns:** Accessor for translated string
|
|
2436
|
+
|
|
2437
|
+
### Constants
|
|
2438
|
+
|
|
2439
|
+
#### `AuthContext`
|
|
2440
|
+
|
|
2441
|
+
```typescript
|
|
2442
|
+
const AuthContext: Context<AuthClient<unknown> | undefined>
|
|
2443
|
+
```
|
|
2444
|
+
|
|
2445
|
+
#### `HttpContext`
|
|
2446
|
+
|
|
2447
|
+
```typescript
|
|
2448
|
+
const HttpContext: Context<HttpClient | undefined>
|
|
2449
|
+
```
|
|
2450
|
+
|
|
2451
|
+
#### `I18nContext`
|
|
2452
|
+
|
|
2453
|
+
```typescript
|
|
2454
|
+
const I18nContext: Context<I18nProvider | undefined>
|
|
2455
|
+
```
|
|
2456
|
+
|
|
2457
|
+
#### `LoggerContext`
|
|
2458
|
+
|
|
2459
|
+
```typescript
|
|
2460
|
+
const LoggerContext: Context<LoggerProvider | undefined>
|
|
2461
|
+
```
|
|
2462
|
+
|
|
2463
|
+
#### `RouterContext`
|
|
2464
|
+
|
|
2465
|
+
```typescript
|
|
2466
|
+
const RouterContext: Context<Router | undefined>
|
|
2467
|
+
```
|
|
2468
|
+
|
|
2469
|
+
#### `StateContext`
|
|
2470
|
+
|
|
2471
|
+
Internal contexts for molecule providers.
|
|
2472
|
+
|
|
2473
|
+
```typescript
|
|
2474
|
+
const StateContext: Context<StateProvider | undefined>
|
|
2475
|
+
```
|
|
2476
|
+
|
|
2477
|
+
#### `StorageContext`
|
|
2478
|
+
|
|
2479
|
+
```typescript
|
|
2480
|
+
const StorageContext: Context<StorageProvider | undefined>
|
|
2481
|
+
```
|
|
2482
|
+
|
|
2483
|
+
#### `ThemeContext`
|
|
2484
|
+
|
|
2485
|
+
```typescript
|
|
2486
|
+
const ThemeContext: Context<ThemeProvider | undefined>
|
|
2487
|
+
```
|
|
2488
|
+
|
|
2489
|
+
## Injection Notes
|
|
2490
|
+
|
|
2491
|
+
### Requirements
|
|
2492
|
+
|
|
2493
|
+
Peer dependencies:
|
|
2494
|
+
|
|
2495
|
+
- `@molecule/app-auth` ^1.0.0
|
|
2496
|
+
- `@molecule/app-device` ^1.0.0
|
|
2497
|
+
- `@molecule/app-forms` ^1.0.0
|
|
2498
|
+
- `@molecule/app-http` ^1.0.0
|
|
2499
|
+
- `@molecule/app-i18n` ^1.0.0
|
|
2500
|
+
- `@molecule/app-logger` ^1.0.0
|
|
2501
|
+
- `@molecule/app-platform` ^1.0.0
|
|
2502
|
+
- `@molecule/app-push` ^1.0.0
|
|
2503
|
+
- `@molecule/app-routing` ^1.0.0
|
|
2504
|
+
- `@molecule/app-state` ^1.0.0
|
|
2505
|
+
- `@molecule/app-storage` ^1.0.0
|
|
2506
|
+
- `@molecule/app-theme` ^1.0.0
|
|
2507
|
+
- `@molecule/app-ui` ^1.0.0
|
|
2508
|
+
- `@molecule/app-utilities` ^1.0.0
|
|
2509
|
+
- `@molecule/app-version` ^1.0.0
|
|
2510
|
+
- `solid-js` ^1.8.0
|
|
2511
|
+
|
|
2512
|
+
### Runtime Dependencies
|
|
2513
|
+
|
|
2514
|
+
- `@molecule/app-auth`
|
|
2515
|
+
- `@molecule/app-device`
|
|
2516
|
+
- `@molecule/app-forms`
|
|
2517
|
+
- `@molecule/app-http`
|
|
2518
|
+
- `@molecule/app-i18n`
|
|
2519
|
+
- `@molecule/app-logger`
|
|
2520
|
+
- `@molecule/app-platform`
|
|
2521
|
+
- `@molecule/app-push`
|
|
2522
|
+
- `@molecule/app-routing`
|
|
2523
|
+
- `@molecule/app-state`
|
|
2524
|
+
- `@molecule/app-storage`
|
|
2525
|
+
- `@molecule/app-theme`
|
|
2526
|
+
- `@molecule/app-ui`
|
|
2527
|
+
- `@molecule/app-utilities`
|
|
2528
|
+
- `@molecule/app-version`
|
|
2529
|
+
- `solid-js`
|
|
2530
|
+
|
|
2531
|
+
- **Primitives throw outside `MoleculeProvider` — and per missing service.** `config` wires
|
|
2532
|
+
ONLY the services you pass; calling `createAuth()` in a tree whose config lacks `auth`
|
|
2533
|
+
throws "getAuthClient must be used within a MoleculeProvider with auth configured". Fix the
|
|
2534
|
+
config, don't catch the error.
|
|
2535
|
+
- Primitive results are Solid accessors — call them (`isAuthenticated()`, `theme()`,
|
|
2536
|
+
`user()`), never read them bare; a bare `theme.colors` is a type error, and a bare
|
|
2537
|
+
`isAuthenticated` is always truthy.
|
|
2538
|
+
- Call primitives at component setup (top level of the component function), not inside JSX
|
|
2539
|
+
callbacks, so subscriptions are established once.
|
|
2540
|
+
|
|
2541
|
+
## Translations
|
|
2542
|
+
|
|
2543
|
+
Translation strings are provided by `@molecule/app-locales-solid`.
|