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