@molecule/app-react 3.4.3 → 3.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +99 -13
  2. package/package.json +2 -2
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-07T05:06:44.123Z
6
+ Generated: 2026-11-08T06:24:47.532Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-react
@@ -200,25 +200,30 @@ interface AuthState<T = UserProfile> {
200
200
  * never signs out. See {@link AuthStatus}.
201
201
  */
202
202
  status: AuthStatus
203
+
203
204
  /**
204
205
  * Whether auth state has been initialized.
205
206
  */
206
207
  initialized: boolean
208
+
207
209
  /**
208
210
  * Whether the client has an authenticated session. This is not a server
209
211
  * confirmation flag: during `'unavailable'` it can be false for a retained
210
212
  * token/cookie-only candidate with no cached profile. Use `status` for redirects.
211
213
  */
212
214
  authenticated: boolean
215
+
213
216
  /**
214
217
  * Current user, or null when none is cached. In particular, an `'unavailable'`
215
218
  * token/cookie-only restore has a retained candidate but no profile yet.
216
219
  */
217
220
  user: T | null
221
+
218
222
  /**
219
223
  * Whether an auth operation is in progress.
220
224
  */
221
225
  loading: boolean
226
+
222
227
  /**
223
228
  * Last auth error (if any).
224
229
  */
@@ -239,58 +244,82 @@ interface AuthClient<
239
244
  > {
240
245
  /** Returns the current authentication state snapshot. */
241
246
  getState(): AuthState<T>
247
+
242
248
  /** Returns whether the user is currently authenticated. */
243
249
  isAuthenticated(): boolean
250
+
244
251
  /** Gets the current user. */
245
252
  getUser(): T | null
253
+
246
254
  /** Optional ownership marker for the current session. */
247
255
  getSessionRevision?(): number
256
+
248
257
  /** Updates the cached user object (state + persistent storage) without hitting the network. */
249
258
  setUser(user: T | null): void
259
+
250
260
  /** Gets the current access token. */
251
261
  getAccessToken(): string | null
262
+
252
263
  /** Stores the access token in the configured token storage adapter (in a browser, Web Storage; `'memory'` where no browser store exists). */
253
264
  setAccessToken(token: string | null): void
265
+
254
266
  /** 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… */
255
267
  setSession(session: AuthSessionSeed<T>): void
268
+
256
269
  /** Gets the refresh token. */
257
270
  getRefreshToken(): string | null
271
+
258
272
  /** Logs in with credentials. */
259
273
  login(credentials: LoginCredentials): Promise<AuthResult<T>>
274
+
260
275
  /** Logs out the current user. */
261
276
  logout(): Promise<void>
277
+
262
278
  /** Registers a new user. */
263
279
  register(data: RegisterData<TRegister>): Promise<AuthResult<T>>
280
+
264
281
  /** Refreshes the access token. */
265
282
  refresh(): Promise<AuthResult<T>>
283
+
266
284
  /** Requests a password reset. */
267
285
  requestPasswordReset(data: PasswordResetRequest): Promise<void>
286
+
268
287
  /** Confirms a password reset. */
269
288
  confirmPasswordReset(data: PasswordResetConfirm): Promise<void>
289
+
270
290
  /** Updates the current user's profile. */
271
291
  updateProfile(data: Partial<T>): Promise<T>
292
+
272
293
  /** Changes the current user's password. */
273
294
  changePassword(oldPassword: string, newPassword: string): Promise<void>
295
+
274
296
  /** Initializes auth state (e.g., from stored tokens). */
275
297
  initialize(): Promise<void>
298
+
276
299
  /** 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… */
277
300
  validateSession?(): Promise<void>
301
+
278
302
  /** Resolves when the session restore started by `initialize()` has settled — the point after which the client knows whether this visitor is signed in. */
279
303
  whenRestored?(): Promise<void>
304
+
280
305
  /** Subscribes to auth state changes. */
281
306
  subscribe(callback: (state: AuthState<T>) => void): () => void
307
+
282
308
  /** Subscribes to auth state changes (alias for subscribe). */
283
309
  onAuthChange(callback: (state: AuthState<T>) => void): () => void
310
+
284
311
  /** Gets the current access token (alias for getAccessToken). */
285
312
  getToken?(): string | null
313
+
286
314
  /** Adds an auth event listener. */
287
315
  addEventListener(listener: AuthEventListener<T>): () => void
316
+
288
317
  /** Destroys the auth client. */
289
318
  destroy(): void
290
319
  }
291
320
  ```
292
321
 
293
- _(Member comments are shortened to their first sentence to fit; the full declaration is in `node_modules/@molecule/app-react/dist`.)_
322
+ _(Member comments are shortened to their first sentence to fit; the full declaration is in `node_modules/@molecule/app-auth/dist/types.d.ts`.)_
294
323
 
295
324
  #### `FormController`
296
325
 
@@ -304,72 +333,77 @@ interface FormController<T extends FormValuesConstraint<T> = Record<string, unkn
304
333
  * Gets the current form state.
305
334
  */
306
335
  getState(): FormState<T>
336
+
307
337
  /**
308
338
  * Gets the value of a specific field.
309
339
  */
310
340
  getValue(name: string): unknown
311
341
  getValue<K extends keyof T>(name: K): T[K]
342
+
312
343
  /**
313
344
  * Gets all form values.
314
345
  */
315
346
  getValues(): T
347
+
316
348
  /**
317
349
  * Sets the value of a specific field.
318
350
  */
319
351
  setValue(
320
352
  name: string,
321
353
  value: unknown,
322
- options?: {
323
- shouldValidate?: boolean
324
- shouldDirty?: boolean
325
- shouldTouch?: boolean
326
- },
354
+ options?: { shouldValidate?: boolean; shouldDirty?: boolean; shouldTouch?: boolean },
327
355
  ): void
356
+
328
357
  /**
329
358
  * Sets multiple values at once.
330
359
  */
331
- setValues(
332
- values: Partial<T>,
333
- options?: {
334
- shouldValidate?: boolean
335
- },
336
- ): void
360
+ setValues(values: Partial<T>, options?: { shouldValidate?: boolean }): void
361
+
337
362
  /**
338
363
  * Gets the error for a specific field.
339
364
  */
340
365
  getError(name: string): string | undefined
366
+
341
367
  /**
342
368
  * Sets the error for a specific field.
343
369
  */
344
370
  setError(name: string, error: string | undefined): void
371
+
345
372
  /**
346
373
  * Clears the error for a specific field.
347
374
  */
348
375
  clearError<K extends keyof T>(name: K): void
376
+
349
377
  /**
350
378
  * Clears all errors.
351
379
  */
352
380
  clearErrors(): void
381
+
353
382
  /**
354
383
  * Gets the field state for a specific field.
355
384
  */
356
385
  getFieldState<K extends keyof T>(name: K): FieldState<T[K]>
386
+
357
387
  /**
358
388
  * Registers a field for form management.
359
389
  */
360
390
  register(nameOrOptions: string | RegisterOptions, options?: RegisterOptions): FieldRegistration
391
+
361
392
  /**
362
393
  * Unregisters a field.
363
394
  */
364
395
  unregister(name: string): void
396
+
365
397
  /**
366
398
  * Validates a specific field.
367
399
  */
368
400
  validateField<K extends keyof T>(name: K): Promise<boolean>
401
+
369
402
  /**
370
403
  * Validates all fields.
371
404
  */
372
405
  validate(): Promise<boolean>
406
+
373
407
  /**
374
408
  * Resets the form and clears errors, touched fields and submission state.
375
409
  *
@@ -381,6 +415,7 @@ interface FormController<T extends FormValuesConstraint<T> = Record<string, unkn
381
415
  * record and cancels a pending submit.
382
416
  */
383
417
  reset(values?: Partial<T>): void
418
+
384
419
  /**
385
420
  * Applies externally loaded values without clearing submission state.
386
421
  *
@@ -391,6 +426,7 @@ interface FormController<T extends FormValuesConstraint<T> = Record<string, unkn
391
426
  * submit. Equal-content baselines cause no update.
392
427
  */
393
428
  updateValues(values: Partial<T>, resetOptions?: FormResetOptions): void
429
+
394
430
  /**
395
431
  * Handles form submission.
396
432
  */
@@ -398,14 +434,17 @@ interface FormController<T extends FormValuesConstraint<T> = Record<string, unkn
398
434
  onSubmit: (values: T) => void | Promise<void>,
399
435
  onError?: (errors: Partial<Record<keyof T, string>>) => void,
400
436
  ): (event?: { preventDefault?: () => void }) => Promise<void>
437
+
401
438
  /**
402
439
  * Sets focus to a field.
403
440
  */
404
441
  setFocus(name: keyof T): void
442
+
405
443
  /**
406
444
  * Subscribes to form state changes.
407
445
  */
408
446
  subscribe(callback: (state: FormState<T>) => void): () => void
447
+
409
448
  /**
410
449
  * Destroys the form controller.
411
450
  */
@@ -439,26 +478,32 @@ interface FormOptions<T extends FormValuesConstraint<T>> {
439
478
  * is created. Mutating this object afterwards does not change the baseline.
440
479
  */
441
480
  defaultValues?: Partial<T>
481
+
442
482
  /**
443
483
  * Externally loaded values, merged over `defaultValues` as the clean
444
484
  * baseline. Framework bindings also apply later content changes; use
445
485
  * `resetOptions.keepDirtyValues` to preserve edits while pristine fields fill.
446
486
  */
447
487
  values?: Partial<T>
488
+
448
489
  /** Controls how framework bindings apply changed `values`. */
449
490
  resetOptions?: FormResetOptions
491
+
450
492
  /**
451
493
  * Validation mode.
452
494
  */
453
495
  mode?: 'onSubmit' | 'onChange' | 'onBlur' | 'all'
496
+
454
497
  /**
455
498
  * Revalidation mode.
456
499
  */
457
500
  reValidateMode?: 'onChange' | 'onBlur' | 'onSubmit'
501
+
458
502
  /**
459
503
  * Whether to focus the first error field on submit.
460
504
  */
461
505
  shouldFocusError?: boolean
506
+
462
507
  /**
463
508
  * Form-level validation function.
464
509
  */
@@ -480,54 +525,65 @@ interface HttpClient {
480
525
  * Base URL for all requests.
481
526
  */
482
527
  baseURL: string
528
+
483
529
  /**
484
530
  * Default headers for all requests.
485
531
  */
486
532
  defaultHeaders: Record<string, string>
533
+
487
534
  /**
488
535
  * Makes a generic HTTP request. `data` is a field of THIS config object — the same body
489
536
  * `post(url, data, config)` takes as its second argument.
490
537
  */
491
538
  request<T = unknown>(config: FullRequestConfig): Promise<HttpResponse<T>>
539
+
492
540
  /**
493
541
  * Makes a GET request.
494
542
  */
495
543
  get<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
544
+
496
545
  /**
497
546
  * Makes a POST request. `data` is the request BODY, not a config object: the wire body is
498
547
  * `data` itself, so `post(url, { data: body })` sends `{"data":body}` — pass `body` directly.
499
548
  * A config (headers, params) is the THIRD argument.
500
549
  */
501
550
  post<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
551
+
502
552
  /**
503
553
  * Makes a PUT request. `data` is the request BODY (second argument) — never `{ data: body }`,
504
554
  * which sends `{"data":body}`; a config is the THIRD argument.
505
555
  */
506
556
  put<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
557
+
507
558
  /**
508
559
  * Makes a PATCH request. `data` is the request BODY (second argument) — never `{ data: body }`,
509
560
  * which sends `{"data":body}`; a config is the THIRD argument.
510
561
  */
511
562
  patch<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
563
+
512
564
  /**
513
565
  * Makes a DELETE request.
514
566
  */
515
567
  delete<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
568
+
516
569
  /**
517
570
  * Adds a request interceptor.
518
571
  * Returns a function to remove the interceptor.
519
572
  */
520
573
  addRequestInterceptor(interceptor: RequestInterceptor): () => void
574
+
521
575
  /**
522
576
  * Adds a response interceptor.
523
577
  * Returns a function to remove the interceptor.
524
578
  */
525
579
  addResponseInterceptor(interceptor: ResponseInterceptor): () => void
580
+
526
581
  /**
527
582
  * Adds an error interceptor.
528
583
  * Returns a function to remove the interceptor.
529
584
  */
530
585
  addErrorInterceptor(interceptor: ErrorInterceptor): () => void
586
+
531
587
  /**
532
588
  * Sets the authorization token.
533
589
  *
@@ -539,11 +595,13 @@ interface HttpClient {
539
595
  * the resolver is removed, the static token is sent again.
540
596
  */
541
597
  setAuthToken(token: string | null): void
598
+
542
599
  /**
543
600
  * Returns the token the client applies to its next request: the resolver's answer when one
544
601
  * is registered, else the static token from `setAuthToken`.
545
602
  */
546
603
  getAuthToken(): string | null
604
+
547
605
  /**
548
606
  * Registers the LIVE token resolver every request of this client reads, or clears it with
549
607
  * `null`.
@@ -574,6 +632,7 @@ interface HttpClient {
574
632
  * @param resolver - Returns the current access token (or null/undefined), or `null` to clear.
575
633
  */
576
634
  setAuthTokenResolver?(resolver: AuthTokenResolver | null): void
635
+
577
636
  /**
578
637
  * Registers a handler for authentication errors (401).
579
638
  *
@@ -595,26 +654,32 @@ interface Router {
595
654
  * Returns the current route location (pathname, search, hash, state).
596
655
  */
597
656
  getLocation(): RouteLocation
657
+
598
658
  /**
599
659
  * Gets the current route params.
600
660
  */
601
661
  getParams<T extends RouteParams = RouteParams>(): T
662
+
602
663
  /**
603
664
  * Gets the current query params.
604
665
  */
605
666
  getQuery(): QueryParams
667
+
606
668
  /**
607
669
  * Gets a specific query parameter.
608
670
  */
609
671
  getQueryParam(key: string): string | undefined
672
+
610
673
  /**
611
674
  * Gets the current hash.
612
675
  */
613
676
  getHash(): string
677
+
614
678
  /**
615
679
  * Navigates to a path.
616
680
  */
617
681
  navigate(path: string, options?: NavigateOptions): void
682
+
618
683
  /**
619
684
  * Navigates to a named route.
620
685
  */
@@ -624,36 +689,44 @@ interface Router {
624
689
  query?: QueryParams,
625
690
  options?: NavigateOptions,
626
691
  ): void
692
+
627
693
  /**
628
694
  * Goes back in history.
629
695
  */
630
696
  back(): void
697
+
631
698
  /**
632
699
  * Goes forward in history.
633
700
  */
634
701
  forward(): void
702
+
635
703
  /**
636
704
  * Goes to a specific point in history.
637
705
  */
638
706
  go(delta: number): void
707
+
639
708
  /**
640
709
  * Updates the current query params.
641
710
  */
642
711
  setQuery(params: QueryParams, options?: NavigateOptions): void
712
+
643
713
  /**
644
714
  * Updates a specific query parameter.
645
715
  */
646
716
  setQueryParam(key: string, value: string | undefined, options?: NavigateOptions): void
717
+
647
718
  /**
648
719
  * Updates the current hash.
649
720
  */
650
721
  setHash(hash: string, options?: NavigateOptions): void
722
+
651
723
  /**
652
724
  * Checks if a path matches the current location.
653
725
  *
654
726
  * @returns `true` if the path matches the current route.
655
727
  */
656
728
  isActive(path: string, exact?: boolean): boolean
729
+
657
730
  /**
658
731
  * Matches a path pattern against a pathname.
659
732
  */
@@ -661,26 +734,32 @@ interface Router {
661
734
  pattern: string,
662
735
  pathname: string,
663
736
  ): RouteMatch<Params> | null
737
+
664
738
  /**
665
739
  * Generates a URL from a named route.
666
740
  */
667
741
  generatePath(name: string, params?: RouteParams, query?: QueryParams): string
742
+
668
743
  /**
669
744
  * Subscribes to route changes.
670
745
  */
671
746
  subscribe(listener: RouteChangeListener): () => void
747
+
672
748
  /**
673
749
  * Adds a navigation guard.
674
750
  */
675
751
  addGuard(guard: NavigationGuard): () => void
752
+
676
753
  /**
677
754
  * Registers route definitions.
678
755
  */
679
756
  registerRoutes(routes: RouteDefinition[]): void
757
+
680
758
  /**
681
759
  * Gets all registered routes.
682
760
  */
683
761
  getRoutes(): RouteDefinition[]
762
+
684
763
  /**
685
764
  * Destroys the router.
686
765
  */
@@ -698,10 +777,12 @@ interface RouterConfig {
698
777
  * Router mode.
699
778
  */
700
779
  mode?: 'history' | 'hash' | 'memory'
780
+
701
781
  /**
702
782
  * Base path.
703
783
  */
704
784
  basePath?: string
785
+
705
786
  /**
706
787
  * Initial routes.
707
788
  */
@@ -719,10 +800,12 @@ interface StoreConfig<T> {
719
800
  * Initial state value.
720
801
  */
721
802
  initialState: T
803
+
722
804
  /**
723
805
  * Optional name for debugging.
724
806
  */
725
807
  name?: string
808
+
726
809
  /**
727
810
  * Optional middleware functions.
728
811
  */
@@ -742,15 +825,18 @@ interface Store<T> {
742
825
  * Gets the current state.
743
826
  */
744
827
  getState(): T
828
+
745
829
  /**
746
830
  * Sets the state (partial or via updater function).
747
831
  */
748
832
  setState(partial: Partial<T> | ((state: T) => Partial<T>)): void
833
+
749
834
  /**
750
835
  * Subscribes to state changes.
751
836
  * Returns an unsubscribe function.
752
837
  */
753
838
  subscribe(listener: StateListener<T>): () => void
839
+
754
840
  /**
755
841
  * Destroys the store and cleans up subscriptions.
756
842
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-react",
3
- "version": "3.4.3",
3
+ "version": "3.4.4",
4
4
  "description": "React framework bindings for molecule.dev",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -61,7 +61,7 @@
61
61
  },
62
62
  "devDependencies": {
63
63
  "@molecule/app-ai-models": "1.4.4",
64
- "@molecule/app-bonds-default-react": "3.0.2",
64
+ "@molecule/app-bonds-default-react": "3.0.3",
65
65
  "@molecule/app-i18n": "1.1.2",
66
66
  "@testing-library/dom": "10.4.2",
67
67
  "@testing-library/react": "16.3.3",