@molecule/app-svelte 3.2.1 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +154 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-11-
|
|
6
|
+
Generated: 2026-11-09T15:44:50.882Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-svelte
|
|
@@ -118,25 +118,30 @@ interface AuthState<T = UserProfile> {
|
|
|
118
118
|
* never signs out. See {@link AuthStatus}.
|
|
119
119
|
*/
|
|
120
120
|
status: AuthStatus
|
|
121
|
+
|
|
121
122
|
/**
|
|
122
123
|
* Whether auth state has been initialized.
|
|
123
124
|
*/
|
|
124
125
|
initialized: boolean
|
|
126
|
+
|
|
125
127
|
/**
|
|
126
128
|
* Whether the client has an authenticated session. This is not a server
|
|
127
129
|
* confirmation flag: during `'unavailable'` it can be false for a retained
|
|
128
130
|
* token/cookie-only candidate with no cached profile. Use `status` for redirects.
|
|
129
131
|
*/
|
|
130
132
|
authenticated: boolean
|
|
133
|
+
|
|
131
134
|
/**
|
|
132
135
|
* Current user, or null when none is cached. In particular, an `'unavailable'`
|
|
133
136
|
* token/cookie-only restore has a retained candidate but no profile yet.
|
|
134
137
|
*/
|
|
135
138
|
user: T | null
|
|
139
|
+
|
|
136
140
|
/**
|
|
137
141
|
* Whether an auth operation is in progress.
|
|
138
142
|
*/
|
|
139
143
|
loading: boolean
|
|
144
|
+
|
|
140
145
|
/**
|
|
141
146
|
* Last auth error (if any).
|
|
142
147
|
*/
|
|
@@ -157,58 +162,82 @@ interface AuthClient<
|
|
|
157
162
|
> {
|
|
158
163
|
/** Returns the current authentication state snapshot. */
|
|
159
164
|
getState(): AuthState<T>
|
|
165
|
+
|
|
160
166
|
/** Returns whether the user is currently authenticated. */
|
|
161
167
|
isAuthenticated(): boolean
|
|
168
|
+
|
|
162
169
|
/** Gets the current user. */
|
|
163
170
|
getUser(): T | null
|
|
171
|
+
|
|
164
172
|
/** Optional ownership marker for the current session. */
|
|
165
173
|
getSessionRevision?(): number
|
|
174
|
+
|
|
166
175
|
/** Updates the cached user object (state + persistent storage) without hitting the network. */
|
|
167
176
|
setUser(user: T | null): void
|
|
177
|
+
|
|
168
178
|
/** Gets the current access token. */
|
|
169
179
|
getAccessToken(): string | null
|
|
180
|
+
|
|
170
181
|
/** Stores the access token in the configured token storage adapter (in a browser, Web Storage; `'memory'` where no browser store exists). */
|
|
171
182
|
setAccessToken(token: string | null): void
|
|
183
|
+
|
|
172
184
|
/** Adopts a session an out-of-band exchange already established: stores the access token (and the refresh token when given), caches the user, and sets the COMPLET… */
|
|
173
185
|
setSession(session: AuthSessionSeed<T>): void
|
|
186
|
+
|
|
174
187
|
/** Gets the refresh token. */
|
|
175
188
|
getRefreshToken(): string | null
|
|
189
|
+
|
|
176
190
|
/** Logs in with credentials. */
|
|
177
191
|
login(credentials: LoginCredentials): Promise<AuthResult<T>>
|
|
192
|
+
|
|
178
193
|
/** Logs out the current user. */
|
|
179
194
|
logout(): Promise<void>
|
|
195
|
+
|
|
180
196
|
/** Registers a new user. */
|
|
181
197
|
register(data: RegisterData<TRegister>): Promise<AuthResult<T>>
|
|
182
|
-
|
|
198
|
+
|
|
199
|
+
/** Exchanges a stored refresh token, or re-reads `currentUserEndpoint` with the existing access token/session cookie when the API has no refresh credential. */
|
|
183
200
|
refresh(): Promise<AuthResult<T>>
|
|
201
|
+
|
|
184
202
|
/** Requests a password reset. */
|
|
185
203
|
requestPasswordReset(data: PasswordResetRequest): Promise<void>
|
|
204
|
+
|
|
186
205
|
/** Confirms a password reset. */
|
|
187
206
|
confirmPasswordReset(data: PasswordResetConfirm): Promise<void>
|
|
207
|
+
|
|
188
208
|
/** Updates the current user's profile. */
|
|
189
209
|
updateProfile(data: Partial<T>): Promise<T>
|
|
210
|
+
|
|
190
211
|
/** Changes the current user's password. */
|
|
191
212
|
changePassword(oldPassword: string, newPassword: string): Promise<void>
|
|
213
|
+
|
|
192
214
|
/** Initializes auth state (e.g., from stored tokens). */
|
|
193
215
|
initialize(): Promise<void>
|
|
216
|
+
|
|
194
217
|
/** Re-checks a restored session against the server, in the background — the boot-time validation an app with a stored token needs when a revoked or expired token… */
|
|
195
218
|
validateSession?(): Promise<void>
|
|
219
|
+
|
|
196
220
|
/** Resolves when the session restore started by `initialize()` has settled — the point after which the client knows whether this visitor is signed in. */
|
|
197
221
|
whenRestored?(): Promise<void>
|
|
222
|
+
|
|
198
223
|
/** Subscribes to auth state changes. */
|
|
199
224
|
subscribe(callback: (state: AuthState<T>) => void): () => void
|
|
225
|
+
|
|
200
226
|
/** Subscribes to auth state changes (alias for subscribe). */
|
|
201
227
|
onAuthChange(callback: (state: AuthState<T>) => void): () => void
|
|
228
|
+
|
|
202
229
|
/** Gets the current access token (alias for getAccessToken). */
|
|
203
230
|
getToken?(): string | null
|
|
231
|
+
|
|
204
232
|
/** Adds an auth event listener. */
|
|
205
233
|
addEventListener(listener: AuthEventListener<T>): () => void
|
|
234
|
+
|
|
206
235
|
/** Destroys the auth client. */
|
|
207
236
|
destroy(): void
|
|
208
237
|
}
|
|
209
238
|
```
|
|
210
239
|
|
|
211
|
-
_(Member comments are shortened to their first sentence to fit; the full declaration is in `node_modules/@molecule/app-
|
|
240
|
+
_(Member comments are shortened to their first sentence to fit; the full declaration is in `node_modules/@molecule/app-auth/dist/types.d.ts`.)_
|
|
212
241
|
|
|
213
242
|
#### `FormController`
|
|
214
243
|
|
|
@@ -222,72 +251,77 @@ interface FormController<T extends FormValuesConstraint<T> = Record<string, unkn
|
|
|
222
251
|
* Gets the current form state.
|
|
223
252
|
*/
|
|
224
253
|
getState(): FormState<T>
|
|
254
|
+
|
|
225
255
|
/**
|
|
226
256
|
* Gets the value of a specific field.
|
|
227
257
|
*/
|
|
228
258
|
getValue(name: string): unknown
|
|
229
259
|
getValue<K extends keyof T>(name: K): T[K]
|
|
260
|
+
|
|
230
261
|
/**
|
|
231
262
|
* Gets all form values.
|
|
232
263
|
*/
|
|
233
264
|
getValues(): T
|
|
265
|
+
|
|
234
266
|
/**
|
|
235
267
|
* Sets the value of a specific field.
|
|
236
268
|
*/
|
|
237
269
|
setValue(
|
|
238
270
|
name: string,
|
|
239
271
|
value: unknown,
|
|
240
|
-
options?: {
|
|
241
|
-
shouldValidate?: boolean
|
|
242
|
-
shouldDirty?: boolean
|
|
243
|
-
shouldTouch?: boolean
|
|
244
|
-
},
|
|
272
|
+
options?: { shouldValidate?: boolean; shouldDirty?: boolean; shouldTouch?: boolean },
|
|
245
273
|
): void
|
|
274
|
+
|
|
246
275
|
/**
|
|
247
276
|
* Sets multiple values at once.
|
|
248
277
|
*/
|
|
249
|
-
setValues(
|
|
250
|
-
|
|
251
|
-
options?: {
|
|
252
|
-
shouldValidate?: boolean
|
|
253
|
-
},
|
|
254
|
-
): void
|
|
278
|
+
setValues(values: Partial<T>, options?: { shouldValidate?: boolean }): void
|
|
279
|
+
|
|
255
280
|
/**
|
|
256
281
|
* Gets the error for a specific field.
|
|
257
282
|
*/
|
|
258
283
|
getError(name: string): string | undefined
|
|
284
|
+
|
|
259
285
|
/**
|
|
260
286
|
* Sets the error for a specific field.
|
|
261
287
|
*/
|
|
262
288
|
setError(name: string, error: string | undefined): void
|
|
289
|
+
|
|
263
290
|
/**
|
|
264
291
|
* Clears the error for a specific field.
|
|
265
292
|
*/
|
|
266
293
|
clearError<K extends keyof T>(name: K): void
|
|
294
|
+
|
|
267
295
|
/**
|
|
268
296
|
* Clears all errors.
|
|
269
297
|
*/
|
|
270
298
|
clearErrors(): void
|
|
299
|
+
|
|
271
300
|
/**
|
|
272
301
|
* Gets the field state for a specific field.
|
|
273
302
|
*/
|
|
274
303
|
getFieldState<K extends keyof T>(name: K): FieldState<T[K]>
|
|
304
|
+
|
|
275
305
|
/**
|
|
276
306
|
* Registers a field for form management.
|
|
277
307
|
*/
|
|
278
308
|
register(nameOrOptions: string | RegisterOptions, options?: RegisterOptions): FieldRegistration
|
|
309
|
+
|
|
279
310
|
/**
|
|
280
311
|
* Unregisters a field.
|
|
281
312
|
*/
|
|
282
313
|
unregister(name: string): void
|
|
314
|
+
|
|
283
315
|
/**
|
|
284
316
|
* Validates a specific field.
|
|
285
317
|
*/
|
|
286
318
|
validateField<K extends keyof T>(name: K): Promise<boolean>
|
|
319
|
+
|
|
287
320
|
/**
|
|
288
321
|
* Validates all fields.
|
|
289
322
|
*/
|
|
290
323
|
validate(): Promise<boolean>
|
|
324
|
+
|
|
291
325
|
/**
|
|
292
326
|
* Resets the form and clears errors, touched fields and submission state.
|
|
293
327
|
*
|
|
@@ -299,6 +333,7 @@ interface FormController<T extends FormValuesConstraint<T> = Record<string, unkn
|
|
|
299
333
|
* record and cancels a pending submit.
|
|
300
334
|
*/
|
|
301
335
|
reset(values?: Partial<T>): void
|
|
336
|
+
|
|
302
337
|
/**
|
|
303
338
|
* Applies externally loaded values without clearing submission state.
|
|
304
339
|
*
|
|
@@ -309,6 +344,7 @@ interface FormController<T extends FormValuesConstraint<T> = Record<string, unkn
|
|
|
309
344
|
* submit. Equal-content baselines cause no update.
|
|
310
345
|
*/
|
|
311
346
|
updateValues(values: Partial<T>, resetOptions?: FormResetOptions): void
|
|
347
|
+
|
|
312
348
|
/**
|
|
313
349
|
* Handles form submission.
|
|
314
350
|
*/
|
|
@@ -316,14 +352,17 @@ interface FormController<T extends FormValuesConstraint<T> = Record<string, unkn
|
|
|
316
352
|
onSubmit: (values: T) => void | Promise<void>,
|
|
317
353
|
onError?: (errors: Partial<Record<keyof T, string>>) => void,
|
|
318
354
|
): (event?: { preventDefault?: () => void }) => Promise<void>
|
|
355
|
+
|
|
319
356
|
/**
|
|
320
357
|
* Sets focus to a field.
|
|
321
358
|
*/
|
|
322
359
|
setFocus(name: keyof T): void
|
|
360
|
+
|
|
323
361
|
/**
|
|
324
362
|
* Subscribes to form state changes.
|
|
325
363
|
*/
|
|
326
364
|
subscribe(callback: (state: FormState<T>) => void): () => void
|
|
365
|
+
|
|
327
366
|
/**
|
|
328
367
|
* Destroys the form controller.
|
|
329
368
|
*/
|
|
@@ -342,26 +381,32 @@ interface FormOptions<T extends FormValuesConstraint<T>> {
|
|
|
342
381
|
* is created. Mutating this object afterwards does not change the baseline.
|
|
343
382
|
*/
|
|
344
383
|
defaultValues?: Partial<T>
|
|
384
|
+
|
|
345
385
|
/**
|
|
346
386
|
* Externally loaded values, merged over `defaultValues` as the clean
|
|
347
387
|
* baseline. Framework bindings also apply later content changes; use
|
|
348
388
|
* `resetOptions.keepDirtyValues` to preserve edits while pristine fields fill.
|
|
349
389
|
*/
|
|
350
390
|
values?: Partial<T>
|
|
391
|
+
|
|
351
392
|
/** Controls how framework bindings apply changed `values`. */
|
|
352
393
|
resetOptions?: FormResetOptions
|
|
394
|
+
|
|
353
395
|
/**
|
|
354
396
|
* Validation mode.
|
|
355
397
|
*/
|
|
356
398
|
mode?: 'onSubmit' | 'onChange' | 'onBlur' | 'all'
|
|
399
|
+
|
|
357
400
|
/**
|
|
358
401
|
* Revalidation mode.
|
|
359
402
|
*/
|
|
360
403
|
reValidateMode?: 'onChange' | 'onBlur' | 'onSubmit'
|
|
404
|
+
|
|
361
405
|
/**
|
|
362
406
|
* Whether to focus the first error field on submit.
|
|
363
407
|
*/
|
|
364
408
|
shouldFocusError?: boolean
|
|
409
|
+
|
|
365
410
|
/**
|
|
366
411
|
* Form-level validation function.
|
|
367
412
|
*/
|
|
@@ -383,54 +428,65 @@ interface HttpClient {
|
|
|
383
428
|
* Base URL for all requests.
|
|
384
429
|
*/
|
|
385
430
|
baseURL: string
|
|
431
|
+
|
|
386
432
|
/**
|
|
387
433
|
* Default headers for all requests.
|
|
388
434
|
*/
|
|
389
435
|
defaultHeaders: Record<string, string>
|
|
436
|
+
|
|
390
437
|
/**
|
|
391
438
|
* Makes a generic HTTP request. `data` is a field of THIS config object — the same body
|
|
392
439
|
* `post(url, data, config)` takes as its second argument.
|
|
393
440
|
*/
|
|
394
441
|
request<T = unknown>(config: FullRequestConfig): Promise<HttpResponse<T>>
|
|
442
|
+
|
|
395
443
|
/**
|
|
396
444
|
* Makes a GET request.
|
|
397
445
|
*/
|
|
398
446
|
get<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
447
|
+
|
|
399
448
|
/**
|
|
400
449
|
* Makes a POST request. `data` is the request BODY, not a config object: the wire body is
|
|
401
450
|
* `data` itself, so `post(url, { data: body })` sends `{"data":body}` — pass `body` directly.
|
|
402
451
|
* A config (headers, params) is the THIRD argument.
|
|
403
452
|
*/
|
|
404
453
|
post<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
454
|
+
|
|
405
455
|
/**
|
|
406
456
|
* Makes a PUT request. `data` is the request BODY (second argument) — never `{ data: body }`,
|
|
407
457
|
* which sends `{"data":body}`; a config is the THIRD argument.
|
|
408
458
|
*/
|
|
409
459
|
put<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
460
|
+
|
|
410
461
|
/**
|
|
411
462
|
* Makes a PATCH request. `data` is the request BODY (second argument) — never `{ data: body }`,
|
|
412
463
|
* which sends `{"data":body}`; a config is the THIRD argument.
|
|
413
464
|
*/
|
|
414
465
|
patch<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
466
|
+
|
|
415
467
|
/**
|
|
416
468
|
* Makes a DELETE request.
|
|
417
469
|
*/
|
|
418
470
|
delete<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
471
|
+
|
|
419
472
|
/**
|
|
420
473
|
* Adds a request interceptor.
|
|
421
474
|
* Returns a function to remove the interceptor.
|
|
422
475
|
*/
|
|
423
476
|
addRequestInterceptor(interceptor: RequestInterceptor): () => void
|
|
477
|
+
|
|
424
478
|
/**
|
|
425
479
|
* Adds a response interceptor.
|
|
426
480
|
* Returns a function to remove the interceptor.
|
|
427
481
|
*/
|
|
428
482
|
addResponseInterceptor(interceptor: ResponseInterceptor): () => void
|
|
483
|
+
|
|
429
484
|
/**
|
|
430
485
|
* Adds an error interceptor.
|
|
431
486
|
* Returns a function to remove the interceptor.
|
|
432
487
|
*/
|
|
433
488
|
addErrorInterceptor(interceptor: ErrorInterceptor): () => void
|
|
489
|
+
|
|
434
490
|
/**
|
|
435
491
|
* Sets the authorization token.
|
|
436
492
|
*
|
|
@@ -442,11 +498,13 @@ interface HttpClient {
|
|
|
442
498
|
* the resolver is removed, the static token is sent again.
|
|
443
499
|
*/
|
|
444
500
|
setAuthToken(token: string | null): void
|
|
501
|
+
|
|
445
502
|
/**
|
|
446
503
|
* Returns the token the client applies to its next request: the resolver's answer when one
|
|
447
504
|
* is registered, else the static token from `setAuthToken`.
|
|
448
505
|
*/
|
|
449
506
|
getAuthToken(): string | null
|
|
507
|
+
|
|
450
508
|
/**
|
|
451
509
|
* Registers the LIVE token resolver every request of this client reads, or clears it with
|
|
452
510
|
* `null`.
|
|
@@ -477,6 +535,7 @@ interface HttpClient {
|
|
|
477
535
|
* @param resolver - Returns the current access token (or null/undefined), or `null` to clear.
|
|
478
536
|
*/
|
|
479
537
|
setAuthTokenResolver?(resolver: AuthTokenResolver | null): void
|
|
538
|
+
|
|
480
539
|
/**
|
|
481
540
|
* Registers a handler for authentication errors (401).
|
|
482
541
|
*
|
|
@@ -498,6 +557,7 @@ interface I18nProvider {
|
|
|
498
557
|
* Gets the current locale.
|
|
499
558
|
*/
|
|
500
559
|
getLocale(): string
|
|
560
|
+
|
|
501
561
|
/**
|
|
502
562
|
* Sets the current locale.
|
|
503
563
|
*
|
|
@@ -512,14 +572,17 @@ interface I18nProvider {
|
|
|
512
572
|
* from a working one until a user notices the wrong language on screen.
|
|
513
573
|
*/
|
|
514
574
|
setLocale(locale: string): Promise<void>
|
|
575
|
+
|
|
515
576
|
/**
|
|
516
577
|
* Gets all available locales.
|
|
517
578
|
*/
|
|
518
579
|
getLocales(): LocaleConfig[]
|
|
580
|
+
|
|
519
581
|
/**
|
|
520
582
|
* Adds a locale.
|
|
521
583
|
*/
|
|
522
584
|
addLocale(config: LocaleConfig): void
|
|
585
|
+
|
|
523
586
|
/**
|
|
524
587
|
* Removes a locale by code, notifying subscribers so language pickers
|
|
525
588
|
* built on `onLocaleChange` re-render their list. If the removed locale
|
|
@@ -531,6 +594,7 @@ interface I18nProvider {
|
|
|
531
594
|
* otherwise.
|
|
532
595
|
*/
|
|
533
596
|
removeLocale(code: string): boolean
|
|
597
|
+
|
|
534
598
|
/**
|
|
535
599
|
* Adds translations to a locale. Auto-creates the locale if it doesn't exist.
|
|
536
600
|
*
|
|
@@ -541,6 +605,7 @@ interface I18nProvider {
|
|
|
541
605
|
* contract on the API side.
|
|
542
606
|
*/
|
|
543
607
|
addTranslations(locale: string, translations: Translations, namespace?: string): void
|
|
608
|
+
|
|
544
609
|
/**
|
|
545
610
|
* Translates a key with optional interpolation values and pluralization.
|
|
546
611
|
*
|
|
@@ -558,11 +623,9 @@ interface I18nProvider {
|
|
|
558
623
|
t(
|
|
559
624
|
key: string,
|
|
560
625
|
values?: InterpolationValues,
|
|
561
|
-
options?: {
|
|
562
|
-
defaultValue?: string
|
|
563
|
-
count?: number
|
|
564
|
-
},
|
|
626
|
+
options?: { defaultValue?: string; count?: number },
|
|
565
627
|
): string
|
|
628
|
+
|
|
566
629
|
/**
|
|
567
630
|
* Checks if a translation key exists.
|
|
568
631
|
*
|
|
@@ -577,46 +640,42 @@ interface I18nProvider {
|
|
|
577
640
|
* @returns `true` if the key has a translation.
|
|
578
641
|
*/
|
|
579
642
|
exists(key: string): boolean
|
|
643
|
+
|
|
580
644
|
/**
|
|
581
645
|
* Formats a number according to the current locale.
|
|
582
646
|
*
|
|
583
647
|
* @returns The locale-formatted number string.
|
|
584
648
|
*/
|
|
585
649
|
formatNumber(value: number, options?: NumberFormatOptions): string
|
|
650
|
+
|
|
586
651
|
/**
|
|
587
652
|
* Formats a date according to the current locale.
|
|
588
653
|
*
|
|
589
654
|
* @returns The locale-formatted date string.
|
|
590
655
|
*/
|
|
591
656
|
formatDate(value: Date | number | string, options?: DateFormatOptions): string
|
|
657
|
+
|
|
592
658
|
/**
|
|
593
659
|
* Formats a relative time (e.g. "2 hours ago").
|
|
594
660
|
*
|
|
595
661
|
* @returns The locale-formatted relative time string.
|
|
596
662
|
*/
|
|
597
|
-
formatRelativeTime(
|
|
598
|
-
|
|
599
|
-
options?: {
|
|
600
|
-
unit?: Intl.RelativeTimeFormatUnit
|
|
601
|
-
},
|
|
602
|
-
): string
|
|
663
|
+
formatRelativeTime(value: Date | number, options?: { unit?: Intl.RelativeTimeFormatUnit }): string
|
|
664
|
+
|
|
603
665
|
/**
|
|
604
666
|
* Formats a list (e.g. "A, B, and C").
|
|
605
667
|
*
|
|
606
668
|
* @returns The locale-formatted list string.
|
|
607
669
|
*/
|
|
608
|
-
formatList(
|
|
609
|
-
|
|
610
|
-
options?: {
|
|
611
|
-
type?: 'conjunction' | 'disjunction' | 'unit'
|
|
612
|
-
},
|
|
613
|
-
): string
|
|
670
|
+
formatList(values: string[], options?: { type?: 'conjunction' | 'disjunction' | 'unit' }): string
|
|
671
|
+
|
|
614
672
|
/**
|
|
615
673
|
* Subscribes to locale changes.
|
|
616
674
|
*
|
|
617
675
|
* @returns An unsubscribe function.
|
|
618
676
|
*/
|
|
619
677
|
onLocaleChange(listener: (locale: string) => void): () => void
|
|
678
|
+
|
|
620
679
|
/**
|
|
621
680
|
* Gets a counter that advances for every change `onLocaleChange` announces:
|
|
622
681
|
* a locale switch, a locale-list change, or translations added for a locale
|
|
@@ -638,24 +697,29 @@ interface I18nProvider {
|
|
|
638
697
|
* @returns The provider's current revision.
|
|
639
698
|
*/
|
|
640
699
|
getRevision?(): number
|
|
700
|
+
|
|
641
701
|
/**
|
|
642
702
|
* Gets the text direction for the current locale.
|
|
643
703
|
*
|
|
644
704
|
* @returns `'ltr'` or `'rtl'`.
|
|
645
705
|
*/
|
|
646
706
|
getDirection(): 'ltr' | 'rtl'
|
|
707
|
+
|
|
647
708
|
/**
|
|
648
709
|
* Checks if a translation key exists (alias for exists).
|
|
649
710
|
*/
|
|
650
711
|
hasKey?(key: string): boolean
|
|
712
|
+
|
|
651
713
|
/**
|
|
652
714
|
* Checks if the provider is ready.
|
|
653
715
|
*/
|
|
654
716
|
isReady?(): boolean
|
|
717
|
+
|
|
655
718
|
/**
|
|
656
719
|
* Registers a callback for when the provider is ready.
|
|
657
720
|
*/
|
|
658
721
|
onReady?(callback: () => void): () => void
|
|
722
|
+
|
|
659
723
|
/**
|
|
660
724
|
* Registers a lazily-loaded content module for automatic reload on locale changes.
|
|
661
725
|
* All registered content is reloaded during `setLocale()` before listeners fire,
|
|
@@ -678,42 +742,52 @@ interface Logger {
|
|
|
678
742
|
* Logs a trace message.
|
|
679
743
|
*/
|
|
680
744
|
trace(message: string, ...args: unknown[]): void
|
|
745
|
+
|
|
681
746
|
/**
|
|
682
747
|
* Logs a debug message.
|
|
683
748
|
*/
|
|
684
749
|
debug(message: string, ...args: unknown[]): void
|
|
750
|
+
|
|
685
751
|
/**
|
|
686
752
|
* Logs an info message.
|
|
687
753
|
*/
|
|
688
754
|
info(message: string, ...args: unknown[]): void
|
|
755
|
+
|
|
689
756
|
/**
|
|
690
757
|
* Logs a warning message.
|
|
691
758
|
*/
|
|
692
759
|
warn(message: string, ...args: unknown[]): void
|
|
760
|
+
|
|
693
761
|
/**
|
|
694
762
|
* Logs an error message.
|
|
695
763
|
*/
|
|
696
764
|
error(message: string | Error, ...args: unknown[]): void
|
|
765
|
+
|
|
697
766
|
/**
|
|
698
767
|
* Sets the log level.
|
|
699
768
|
*/
|
|
700
769
|
setLevel(level: LogLevel): void
|
|
770
|
+
|
|
701
771
|
/**
|
|
702
772
|
* Gets the current log level.
|
|
703
773
|
*/
|
|
704
774
|
getLevel(): LogLevel
|
|
775
|
+
|
|
705
776
|
/**
|
|
706
777
|
* Creates a child logger with a namespace.
|
|
707
778
|
*/
|
|
708
779
|
child(name: string, context?: Record<string, unknown>): Logger
|
|
780
|
+
|
|
709
781
|
/**
|
|
710
782
|
* Adds additional context to the logger.
|
|
711
783
|
*/
|
|
712
784
|
withContext(context: Record<string, unknown>): Logger
|
|
785
|
+
|
|
713
786
|
/**
|
|
714
787
|
* Adds a transport.
|
|
715
788
|
*/
|
|
716
789
|
addTransport(transport: LogTransport): () => void
|
|
790
|
+
|
|
717
791
|
/**
|
|
718
792
|
* Removes a transport.
|
|
719
793
|
*/
|
|
@@ -732,30 +806,37 @@ interface LoggerProvider {
|
|
|
732
806
|
* Gets a logger by name, or the root logger if no name given.
|
|
733
807
|
*/
|
|
734
808
|
getLogger(name?: string): Logger
|
|
809
|
+
|
|
735
810
|
/**
|
|
736
811
|
* Creates a named logger.
|
|
737
812
|
*/
|
|
738
813
|
createLogger(nameOrConfig: string | LoggerConfig, config?: LoggerConfig): Logger
|
|
814
|
+
|
|
739
815
|
/**
|
|
740
816
|
* Sets the global log level.
|
|
741
817
|
*/
|
|
742
818
|
setLevel(level: LogLevel): void
|
|
819
|
+
|
|
743
820
|
/**
|
|
744
821
|
* Gets the global log level.
|
|
745
822
|
*/
|
|
746
823
|
getLevel(): LogLevel
|
|
824
|
+
|
|
747
825
|
/**
|
|
748
826
|
* Adds a global transport.
|
|
749
827
|
*/
|
|
750
828
|
addTransport(transport: LogTransport): () => void
|
|
829
|
+
|
|
751
830
|
/**
|
|
752
831
|
* Enables logging.
|
|
753
832
|
*/
|
|
754
833
|
enable(): void
|
|
834
|
+
|
|
755
835
|
/**
|
|
756
836
|
* Disables logging.
|
|
757
837
|
*/
|
|
758
838
|
disable(): void
|
|
839
|
+
|
|
759
840
|
/**
|
|
760
841
|
* Checks if logging is enabled.
|
|
761
842
|
*
|
|
@@ -775,18 +856,22 @@ interface RouteLocation {
|
|
|
775
856
|
* Current pathname.
|
|
776
857
|
*/
|
|
777
858
|
pathname: string
|
|
859
|
+
|
|
778
860
|
/**
|
|
779
861
|
* Query string (including leading ?).
|
|
780
862
|
*/
|
|
781
863
|
search: string
|
|
864
|
+
|
|
782
865
|
/**
|
|
783
866
|
* Hash (including leading #).
|
|
784
867
|
*/
|
|
785
868
|
hash: string
|
|
869
|
+
|
|
786
870
|
/**
|
|
787
871
|
* State data passed with navigation.
|
|
788
872
|
*/
|
|
789
873
|
state?: unknown
|
|
874
|
+
|
|
790
875
|
/**
|
|
791
876
|
* Unique key for this location.
|
|
792
877
|
*/
|
|
@@ -806,26 +891,32 @@ interface Router {
|
|
|
806
891
|
* Returns the current route location (pathname, search, hash, state).
|
|
807
892
|
*/
|
|
808
893
|
getLocation(): RouteLocation
|
|
894
|
+
|
|
809
895
|
/**
|
|
810
896
|
* Gets the current route params.
|
|
811
897
|
*/
|
|
812
898
|
getParams<T extends RouteParams = RouteParams>(): T
|
|
899
|
+
|
|
813
900
|
/**
|
|
814
901
|
* Gets the current query params.
|
|
815
902
|
*/
|
|
816
903
|
getQuery(): QueryParams
|
|
904
|
+
|
|
817
905
|
/**
|
|
818
906
|
* Gets a specific query parameter.
|
|
819
907
|
*/
|
|
820
908
|
getQueryParam(key: string): string | undefined
|
|
909
|
+
|
|
821
910
|
/**
|
|
822
911
|
* Gets the current hash.
|
|
823
912
|
*/
|
|
824
913
|
getHash(): string
|
|
914
|
+
|
|
825
915
|
/**
|
|
826
916
|
* Navigates to a path.
|
|
827
917
|
*/
|
|
828
918
|
navigate(path: string, options?: NavigateOptions): void
|
|
919
|
+
|
|
829
920
|
/**
|
|
830
921
|
* Navigates to a named route.
|
|
831
922
|
*/
|
|
@@ -835,36 +926,44 @@ interface Router {
|
|
|
835
926
|
query?: QueryParams,
|
|
836
927
|
options?: NavigateOptions,
|
|
837
928
|
): void
|
|
929
|
+
|
|
838
930
|
/**
|
|
839
931
|
* Goes back in history.
|
|
840
932
|
*/
|
|
841
933
|
back(): void
|
|
934
|
+
|
|
842
935
|
/**
|
|
843
936
|
* Goes forward in history.
|
|
844
937
|
*/
|
|
845
938
|
forward(): void
|
|
939
|
+
|
|
846
940
|
/**
|
|
847
941
|
* Goes to a specific point in history.
|
|
848
942
|
*/
|
|
849
943
|
go(delta: number): void
|
|
944
|
+
|
|
850
945
|
/**
|
|
851
946
|
* Updates the current query params.
|
|
852
947
|
*/
|
|
853
948
|
setQuery(params: QueryParams, options?: NavigateOptions): void
|
|
949
|
+
|
|
854
950
|
/**
|
|
855
951
|
* Updates a specific query parameter.
|
|
856
952
|
*/
|
|
857
953
|
setQueryParam(key: string, value: string | undefined, options?: NavigateOptions): void
|
|
954
|
+
|
|
858
955
|
/**
|
|
859
956
|
* Updates the current hash.
|
|
860
957
|
*/
|
|
861
958
|
setHash(hash: string, options?: NavigateOptions): void
|
|
959
|
+
|
|
862
960
|
/**
|
|
863
961
|
* Checks if a path matches the current location.
|
|
864
962
|
*
|
|
865
963
|
* @returns `true` if the path matches the current route.
|
|
866
964
|
*/
|
|
867
965
|
isActive(path: string, exact?: boolean): boolean
|
|
966
|
+
|
|
868
967
|
/**
|
|
869
968
|
* Matches a path pattern against a pathname.
|
|
870
969
|
*/
|
|
@@ -872,26 +971,32 @@ interface Router {
|
|
|
872
971
|
pattern: string,
|
|
873
972
|
pathname: string,
|
|
874
973
|
): RouteMatch<Params> | null
|
|
974
|
+
|
|
875
975
|
/**
|
|
876
976
|
* Generates a URL from a named route.
|
|
877
977
|
*/
|
|
878
978
|
generatePath(name: string, params?: RouteParams, query?: QueryParams): string
|
|
979
|
+
|
|
879
980
|
/**
|
|
880
981
|
* Subscribes to route changes.
|
|
881
982
|
*/
|
|
882
983
|
subscribe(listener: RouteChangeListener): () => void
|
|
984
|
+
|
|
883
985
|
/**
|
|
884
986
|
* Adds a navigation guard.
|
|
885
987
|
*/
|
|
886
988
|
addGuard(guard: NavigationGuard): () => void
|
|
989
|
+
|
|
887
990
|
/**
|
|
888
991
|
* Registers route definitions.
|
|
889
992
|
*/
|
|
890
993
|
registerRoutes(routes: RouteDefinition[]): void
|
|
994
|
+
|
|
891
995
|
/**
|
|
892
996
|
* Gets all registered routes.
|
|
893
997
|
*/
|
|
894
998
|
getRoutes(): RouteDefinition[]
|
|
999
|
+
|
|
895
1000
|
/**
|
|
896
1001
|
* Destroys the router.
|
|
897
1002
|
*/
|
|
@@ -909,10 +1014,12 @@ interface StoreConfig<T> {
|
|
|
909
1014
|
* Initial state value.
|
|
910
1015
|
*/
|
|
911
1016
|
initialState: T
|
|
1017
|
+
|
|
912
1018
|
/**
|
|
913
1019
|
* Optional name for debugging.
|
|
914
1020
|
*/
|
|
915
1021
|
name?: string
|
|
1022
|
+
|
|
916
1023
|
/**
|
|
917
1024
|
* Optional middleware functions.
|
|
918
1025
|
*/
|
|
@@ -932,15 +1039,18 @@ interface Store<T> {
|
|
|
932
1039
|
* Gets the current state.
|
|
933
1040
|
*/
|
|
934
1041
|
getState(): T
|
|
1042
|
+
|
|
935
1043
|
/**
|
|
936
1044
|
* Sets the state (partial or via updater function).
|
|
937
1045
|
*/
|
|
938
1046
|
setState(partial: Partial<T> | ((state: T) => Partial<T>)): void
|
|
1047
|
+
|
|
939
1048
|
/**
|
|
940
1049
|
* Subscribes to state changes.
|
|
941
1050
|
* Returns an unsubscribe function.
|
|
942
1051
|
*/
|
|
943
1052
|
subscribe(listener: StateListener<T>): () => void
|
|
1053
|
+
|
|
944
1054
|
/**
|
|
945
1055
|
* Destroys the store and cleans up subscriptions.
|
|
946
1056
|
*/
|
|
@@ -974,34 +1084,42 @@ interface StorageProvider {
|
|
|
974
1084
|
* Gets a value from storage.
|
|
975
1085
|
*/
|
|
976
1086
|
get<T = unknown>(key: string): Promise<T | null>
|
|
1087
|
+
|
|
977
1088
|
/**
|
|
978
1089
|
* Sets a value in storage.
|
|
979
1090
|
*/
|
|
980
1091
|
set<T = unknown>(key: string, value: T): Promise<void>
|
|
1092
|
+
|
|
981
1093
|
/**
|
|
982
1094
|
* Removes a value from storage.
|
|
983
1095
|
*/
|
|
984
1096
|
remove(key: string): Promise<void>
|
|
1097
|
+
|
|
985
1098
|
/**
|
|
986
1099
|
* Clears all values from storage.
|
|
987
1100
|
*/
|
|
988
1101
|
clear(): Promise<void>
|
|
1102
|
+
|
|
989
1103
|
/**
|
|
990
1104
|
* Gets all keys in storage.
|
|
991
1105
|
*/
|
|
992
1106
|
keys(): Promise<string[]>
|
|
1107
|
+
|
|
993
1108
|
/**
|
|
994
1109
|
* Gets multiple values from storage.
|
|
995
1110
|
*/
|
|
996
1111
|
getMany?<T = unknown>(keys: string[]): Promise<Map<string, T | null>>
|
|
1112
|
+
|
|
997
1113
|
/**
|
|
998
1114
|
* Sets multiple values in storage.
|
|
999
1115
|
*/
|
|
1000
1116
|
setMany?<T = unknown>(entries: Array<[string, T]>): Promise<void>
|
|
1117
|
+
|
|
1001
1118
|
/**
|
|
1002
1119
|
* Removes multiple values from storage.
|
|
1003
1120
|
*/
|
|
1004
1121
|
removeMany?(keys: string[]): Promise<void>
|
|
1122
|
+
|
|
1005
1123
|
/**
|
|
1006
1124
|
* Reads a value synchronously.
|
|
1007
1125
|
*
|
|
@@ -1015,6 +1133,7 @@ interface StorageProvider {
|
|
|
1015
1133
|
* @returns The stored value, or `null` when it is absent, unreadable or corrupt.
|
|
1016
1134
|
*/
|
|
1017
1135
|
getSync?<T = unknown>(key: string): T | null
|
|
1136
|
+
|
|
1018
1137
|
/**
|
|
1019
1138
|
* Subscribes to changes made to a key OUTSIDE this provider instance — for
|
|
1020
1139
|
* example another browser tab's `localStorage` write.
|
|
@@ -1041,16 +1160,19 @@ interface ThemeProvider {
|
|
|
1041
1160
|
* Returns the currently active theme.
|
|
1042
1161
|
*/
|
|
1043
1162
|
getTheme(): Theme
|
|
1163
|
+
|
|
1044
1164
|
/**
|
|
1045
1165
|
* Sets the active theme by reference or by name.
|
|
1046
1166
|
*
|
|
1047
1167
|
* @param theme - A `Theme` object or a theme name string to activate.
|
|
1048
1168
|
*/
|
|
1049
1169
|
setTheme(theme: Theme | string): void
|
|
1170
|
+
|
|
1050
1171
|
/**
|
|
1051
1172
|
* Toggles between light and dark mode for the active theme.
|
|
1052
1173
|
*/
|
|
1053
1174
|
toggleMode(): void
|
|
1175
|
+
|
|
1054
1176
|
/**
|
|
1055
1177
|
* Subscribes to theme changes. The callback fires whenever
|
|
1056
1178
|
* `setTheme()` or `toggleMode()` is called.
|
|
@@ -1059,11 +1181,13 @@ interface ThemeProvider {
|
|
|
1059
1181
|
* @returns An unsubscribe function.
|
|
1060
1182
|
*/
|
|
1061
1183
|
subscribe(callback: (theme: Theme) => void): () => void
|
|
1184
|
+
|
|
1062
1185
|
/**
|
|
1063
1186
|
* Returns all registered themes. Optional — not all providers
|
|
1064
1187
|
* support multiple themes.
|
|
1065
1188
|
*/
|
|
1066
1189
|
getThemes?(): Theme[]
|
|
1190
|
+
|
|
1067
1191
|
/**
|
|
1068
1192
|
* Returns the theme a render WITHOUT a browser produces — a server or
|
|
1069
1193
|
* build-time render, which has no storage and no `prefers-color-scheme`
|